This commit is contained in:
mmrbnjd
2025-01-23 02:44:11 +03:30
parent e40192c428
commit 505adf6ab2
12 changed files with 168 additions and 92 deletions

View File

@@ -95,6 +95,21 @@ namespace Back.Common
return new PagingDto<T>(rowCount, PageCount, await values.Skip(skip).Take(take).ToListAsync()); return new PagingDto<T>(rowCount, PageCount, await values.Skip(skip).Take(take).ToListAsync());
} }
}
public static async Task<PagingDto<T>> Paging<T>(this IEnumerable<T> values, int pageId, int take)
{
if (/*values.Count()<1000 && */pageId == 0 && take == 0)
{
return new PagingDto<T>(values.Count(), 1, values.ToList());
}
else
{
int skip = (pageId - 1) * take;
int rowCount = values.Count();
int PageCount = rowCount % take == 0 ? rowCount / take : rowCount / take + 1;
return new PagingDto<T>(rowCount, PageCount, values.Skip(skip).Take(take).ToList());
}
} }
public static System.Linq.Expressions.Expression<Func<TEntity, bool>> GetFunc<TEntity>(string Fild, string Value) public static System.Linq.Expressions.Expression<Func<TEntity, bool>> GetFunc<TEntity>(string Fild, string Value)
{ {

View File

@@ -27,7 +27,7 @@ namespace Back.Services.Warehouse
{ {
var model = new Receipt() var model = new Receipt()
{ {
Date = item.Date, Date = item.Date.Replace("/",""),
CODID = item.CODID, CODID = item.CODID,
Count = item.Count, Count = item.Count,
ForSale = item.ForSale, ForSale = item.ForSale,
@@ -60,7 +60,7 @@ namespace Back.Services.Warehouse
public async Task<ReceiptDto?> Update(ReceiptDto item) public async Task<ReceiptDto?> Update(ReceiptDto item)
{ {
var model= await _ReceiptRepo.Get(w => w.ID == item.ID).FirstOrDefaultAsync(); var model= await _ReceiptRepo.Get(w => w.ID == item.ID).FirstOrDefaultAsync();
model.Date= item.Date; model.Date= item.Date.Replace("/", "");
model.CODID= item.CODID; model.CODID= item.CODID;
model.Count= item.Count; model.Count= item.Count;
model.ForSale= item.ForSale; model.ForSale= item.ForSale;

View File

@@ -19,7 +19,7 @@ namespace Back.Services.Warehouse
{ {
var model = new Remittance() var model = new Remittance()
{ {
Date = item.Date, Date = item.Date.Replace("/", ""),
CODID = item.CODID, CODID = item.CODID,
Count = item.Count, Count = item.Count,
info = item.info, info = item.info,
@@ -44,7 +44,7 @@ namespace Back.Services.Warehouse
public async Task<RemittanceDto?> Update(RemittanceDto item) public async Task<RemittanceDto?> Update(RemittanceDto item)
{ {
var model = await _ReceiptRepo.Get(w => w.ID == item.ID).FirstOrDefaultAsync(); var model = await _ReceiptRepo.Get(w => w.ID == item.ID).FirstOrDefaultAsync();
model.Date = item.Date; model.Date = item.Date.Replace("/", "");
model.CODID = item.CODID; model.CODID = item.CODID;
model.Count = item.Count; model.Count = item.Count;
model.info = item.info; model.info = item.info;

View File

@@ -1,4 +1,5 @@
using Back.Common; 
using Back.Common;
using Back.Data.Contracts; using Back.Data.Contracts;
using Back.Data.Models.Warehouse; using Back.Data.Models.Warehouse;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -36,7 +37,7 @@ namespace Back.Services.Warehouse
info = s.info, info = s.info,
Type = TypeCirculation.Remittance, Type = TypeCirculation.Remittance,
ModelTypeID = (int)s.Type, ModelTypeID = (int)s.Type,
ModelTypeTitle = s.Type.GetDisplayName(), ModelTypeTitle = s.Type.GetEnumDisplayName(),
invoiceID = s.InvoiceID, invoiceID = s.InvoiceID,
}); });
if (!string.IsNullOrEmpty(date)) if (!string.IsNullOrEmpty(date))
@@ -55,24 +56,23 @@ namespace Back.Services.Warehouse
info = s.info, info = s.info,
Type = TypeCirculation.Receipt, Type = TypeCirculation.Receipt,
ModelTypeID = (int)s.Type, ModelTypeID = (int)s.Type,
ModelTypeTitle = s.Type.GetDisplayName(), ModelTypeTitle = s.Type.GetEnumDisplayName(),
invoiceID = s.InvoiceID, invoiceID = s.InvoiceID,
ForSale = s.ForSale,
}); });
if (!string.IsNullOrEmpty(date)) if (!string.IsNullOrEmpty(date))
RequestReceipt = RequestReceipt.Where(w => w.Date == date); RequestReceipt = RequestReceipt.Where(w => w.Date == date);
if (CODID != 0) if (CODID != 0)
RequestReceipt = RequestReceipt.Where(w => w.CODID == CODID); RequestReceipt = RequestReceipt.Where(w => w.CODID == CODID);
try
{
var item = await RequestReceipt.Union(RequestRemittance).OrderByDescending(o => o.Date).ToListAsync();
} var itemsReceipt = await RequestReceipt.ToListAsync();
catch (Exception ex) var Remittance = await RequestRemittance.ToListAsync();
{
throw;
} return await itemsReceipt.Union(Remittance).OrderByDescending(o => o.Date).Paging(PageIndex, PageSize);
return await RequestReceipt.Union(RequestRemittance).OrderByDescending(o => o.Date).Paging(PageIndex, PageSize);
// return await RequestReceipt.Union(RequestRemittance).OrderByDescending(o => o.Date).Paging(PageIndex, PageSize);
//var list = await RequestReceipt.ToListAsync(); //var list = await RequestReceipt.ToListAsync();
//list.AddRange(await RequestRemittance.ToListAsync()); //list.AddRange(await RequestRemittance.ToListAsync());
//return await list.OrderByDescending(o=>o.Date).AsQueryable().Paging(PageIndex, PageSize); //return await list.OrderByDescending(o=>o.Date).AsQueryable().Paging(PageIndex, PageSize);

View File

@@ -16,7 +16,7 @@ namespace Back.Validations.Warehouse.Receipt
RuleFor(model => model) RuleFor(model => model)
.Custom((model, context) => { .Custom((model, context) => {
if (servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result) if (!servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
context.AddFailure("کد کالا یافت نشد"); context.AddFailure("کد کالا یافت نشد");
}); });

View File

@@ -26,17 +26,11 @@ namespace Back.Validations.Warehouse.Receipt
context.AddFailure("رسید یافت نشد"); context.AddFailure("رسید یافت نشد");
else else
{ {
if (ORGitem.CODID != model.Item1.CODID)
{
if (servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
context.AddFailure("کد کالا یافت نشد");
}
else
{
if (ORGitem.CODID != model.Item1.CODID) if (ORGitem.CODID != model.Item1.CODID)
{ {
context.AddFailure("در رسید امکان ویرایش کالا انکان پذیر نیست"); context.AddFailure("در رسید امکان ویرایش کالا امکان پذیر نیست");
} }
else else
{ {
@@ -69,7 +63,7 @@ namespace Back.Validations.Warehouse.Receipt
} }
}
} }
}); });

View File

@@ -14,7 +14,7 @@ namespace Back.Validations.Warehouse.Remittance
RuleFor(model => model) RuleFor(model => model)
.Custom((model, context) => .Custom((model, context) =>
{ {
if (servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result) if (!servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
context.AddFailure("کد کالا یافت نشد"); context.AddFailure("کد کالا یافت نشد");
}); });

View File

@@ -27,7 +27,7 @@ namespace Back.Validations.Warehouse.Remittance
if (ORGitem.CODID != model.Item1.CODID) if (ORGitem.CODID != model.Item1.CODID)
{ {
context.AddFailure("در حئاله امکان ویرایش کالا انکان پذیر نیست"); context.AddFailure("در حواله امکان ویرایش کالا امکان پذیر نیست");
} }
else else
{ {

View File

@@ -13,14 +13,19 @@
@alertMessage @alertMessage
</Alert> </Alert>
</div> </div>
<ul>
@if (_UsedFromInvoice) @if (_UsedFromInvoice)
{ {
<ul>
<li> style="color:indianred"این سند از فاکتور صادر شده، ویرایش مستقیم آن ممکن نیست</li> <li> style="color:indianred"این سند از فاکتور صادر شده، ویرایش مستقیم آن ممکن نیست</li>
<br /> <br />
}
</ul> </ul>
<div class="col-md-2"> }
<div class="row g-3">
<div class="form-group col-md-6">
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">کالا</label>
<AutoComplete @bind-Value="model.CODTitle" <AutoComplete @bind-Value="model.CODTitle"
TItem="CODIdName<int>" TItem="CODIdName<int>"
DataProvider="CODDataProvider" DataProvider="CODDataProvider"
@@ -28,24 +33,19 @@
Placeholder="جستجو در کالا..." Placeholder="جستجو در کالا..."
OnChanged="(CODIdName<int> cod) => OnAutoCompleteChanged(cod)" /> OnChanged="(CODIdName<int> cod) => OnAutoCompleteChanged(cod)" />
</div> </div>
@* <div class="col-md-2"> <div class="form-group col-md-3">
<select style="text-align:center" @bind="Doctype" class="form-control" aria-label="Default select example"> <label class="col-sm-4 col-form-label" style="color:red">تعداد</label>
<option value="0" style="color: #b5b5b5" selected>نوع ...</option> <InputNumber @bind-Value="model.Count" style="text-align:center" type="text" class="form-control" placeholder="تعداد" />
<option value="10">رسید</option>
<option value="20">حواله</option>
</select>
</div> *@
<div class="form-group col-md-2">
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">تعداد</label>
<InputNumber @bind-Value="model.Count" type="text" class="form-control" id="inputam" placeholder="تعداد" />
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-3">
<label class="col-sm-5 col-form-label" for="inputInvoicIssueDate">تاریخ</label> <label class="col-sm-5 col-form-label" for="inputInvoicIssueDate">تاریخ</label>
<InputText style=" text-align: center;" @bind-Value="model.Date" type="text" class="form-control" id="inputInvoicIssueDate" placeholder="تاریخ" /> <InputText style=" text-align: center;" @bind-Value="model.Date" type="text" class="form-control" id="inputInvoicIssueDate" placeholder="تاریخ" />
</div> </div>
</div>
<div class="row g-3">
<div class="col-md-4">
<label class="col-sm-4 col-form-label" style="color:red">نوع سند</label>
<div class="col-md-2">
<select style="text-align:center" @bind="model.ModelTypeID" class="form-control" aria-label="Default select example"> <select style="text-align:center" @bind="model.ModelTypeID" class="form-control" aria-label="Default select example">
<option value="0" style="color: #b5b5b5" selected>نوع سند ...</option> <option value="0" style="color: #b5b5b5" selected>نوع سند ...</option>
@if (model.Type == TypeCirculation.Receipt) @if (model.Type == TypeCirculation.Receipt)
@@ -63,22 +63,37 @@
</select> </select>
</div> </div>
@if (model.Type == TypeCirculation.Receipt) <div class="form-group col-md-8">
{
<div class="col-md-2">
<Switch @bind-Value="forsale" Label="اجازه فروش" />
</div>
}
<div class="form-group col-md-4">
<label class="col-form-label" for="inputdes">توضیحات</label> <label class="col-form-label" for="inputdes">توضیحات</label>
<InputText @bind-Value="model.info" type="text" class="form-control" id="inputdes" placeholder="توضیحات" /> <InputText @bind-Value="model.info" type="text" class="form-control" id="inputdes" placeholder="توضیحات" />
</div> </div>
</div>
@* <div class="col-md-2">
<select style="text-align:center" @bind="Doctype" class="form-control" aria-label="Default select example">
<option value="0" style="color: #b5b5b5" selected>نوع ...</option>
<option value="10">رسید</option>
<option value="20">حواله</option>
</select>
</div> *@
@if (model.Type == TypeCirculation.Receipt)
{
<div class="row g-3">
<div class="form-group col-md-4" style="margin-top:30px">
<Switch @bind-Value="forsale" Label="اجازه فروش" />
</div>
</div>
}
</form> </form>
<div class="row g-3"> <div class="row g-3">
<div class="col-md-10"> <div class="col-md-10">
@if (model.CODID == 0) @if (NewItem)
{ {
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAddOrUpdate" Type="ButtonType.Button"> <Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAddOrUpdate" Type="ButtonType.Button">
جدید جدید
@@ -117,11 +132,16 @@
public bool SpinnerVisible { get; set; } = false; public bool SpinnerVisible { get; set; } = false;
private bool forsale { get; set; } = false; private bool forsale { get; set; } = true;
} }
@functions { @functions {
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
if (NewItem)
forsale = true;
else
forsale = model.ForSale.HasValue ? model.ForSale.Value : false;
_UsedFromInvoice = model.invoiceID.HasValue; _UsedFromInvoice = model.invoiceID.HasValue;
if (NewItem) if (NewItem)
model.Date = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront(); model.Date = DateTime.Now.ConvertMiladiToShamsiinFront().ShamciToFormatShamciinFront();
@@ -178,6 +198,11 @@
} }
private async Task Addorupdate() private async Task Addorupdate()
{ {
if ((model.Type == TypeCirculation.Receipt && !await ValidateReceipt())
|| (model.Type == TypeCirculation.Remittance && !await ValidateRemittance()))
return;
string controller = model.Type == TypeCirculation.Receipt ? "Receipt" : "Remittance"; string controller = model.Type == TypeCirculation.Receipt ? "Receipt" : "Remittance";
string route = NewItem ? "ADD" : "Update"; string route = NewItem ? "ADD" : "Update";
ActionInResultComponent result = new ActionInResultComponent(); ActionInResultComponent result = new ActionInResultComponent();
@@ -186,7 +211,7 @@
if (NewItem) if (NewItem)
{ {
if (model.Type == TypeCirculation.Receipt) if (model.Type == TypeCirculation.Receipt)
rsp = await hc.Post($"{controller}/{NewItem}/{model.ID}", new ReceiptDto() rsp = await hc.Post($"{controller}/{route}", new ReceiptDto()
{ {
CODID = model.CODID, CODID = model.CODID,
Count = model.Count, Count = model.Count,
@@ -197,7 +222,7 @@
}); });
if (model.Type == TypeCirculation.Remittance) if (model.Type == TypeCirculation.Remittance)
rsp = await hc.Post($"{route}/Update/{model.ID}", new RemittanceDto() rsp = await hc.Post($"{controller}/{route}", new RemittanceDto()
{ {
CODID = model.CODID, CODID = model.CODID,
Count = model.Count, Count = model.Count,
@@ -210,8 +235,9 @@
else else
{ {
if (model.Type == TypeCirculation.Receipt) if (model.Type == TypeCirculation.Receipt)
rsp = await hc.Put($"{controller}/{NewItem}/{model.ID}", new ReceiptDto() rsp = await hc.Put($"{controller}/{route}", new ReceiptDto()
{ {
ID = model.ID,
CODID = model.CODID, CODID = model.CODID,
Count = model.Count, Count = model.Count,
Date = model.Date, Date = model.Date,
@@ -221,8 +247,9 @@
}); });
if (model.Type == TypeCirculation.Remittance) if (model.Type == TypeCirculation.Remittance)
rsp = await hc.Put($"{route}/Update/{model.ID}", new RemittanceDto() rsp = await hc.Put($"{controller}/{route}", new RemittanceDto()
{ {
ID = model.ID,
CODID = model.CODID, CODID = model.CODID,
Count = model.Count, Count = model.Count,
Date = model.Date, Date = model.Date,
@@ -242,9 +269,18 @@
} }
else else
{
try
{ {
var request = await rsp.Content.ReadFromJsonAsync<List<string>>(); var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]); ShowDangerAlert(request[0]);
}
catch (Exception)
{
ShowDangerAlert("حظای سیستمی");
}
} }
} }
public async Task OnClickAddOrUpdate() public async Task OnClickAddOrUpdate()
@@ -298,13 +334,13 @@
if (model.CODID == null || model.CODID == 0) if (model.CODID == null || model.CODID == 0)
ShowDangerAlert("کالایی انتخاب کنید"); ShowDangerAlert("کالایی انتخاب کنید");
if (model.Count <= 0) else if (model.Count <= 0)
ShowDangerAlert("تعدادی وارد کنید"); ShowDangerAlert("تعدادی وارد کنید");
if (string.IsNullOrEmpty(model.Date)) else if (string.IsNullOrEmpty(model.Date))
ShowDangerAlert("تاریخ را مشخص کنید"); ShowDangerAlert("تاریخ را مشخص کنید");
if (model.Date.Replace("/", "").Length != 10) else if (model.Date.Replace("/", "").Length != 8)
ShowDangerAlert("تاریخ صحیح نمی باشد"); ShowDangerAlert("تاریخ صحیح نمی باشد");
if (string.IsNullOrEmpty(model.info)) else if (string.IsNullOrEmpty(model.info))
ShowDangerAlert("توضیحی مشخص کنید"); ShowDangerAlert("توضیحی مشخص کنید");
else return true; else return true;

View File

@@ -44,12 +44,42 @@
if (property.CustomAttributes.Any(w => w.AttributeType.Name == "DisplayAttribute")) if (property.CustomAttributes.Any(w => w.AttributeType.Name == "DisplayAttribute"))
{ {
if (property.PropertyType == typeof(Nullable<System.Decimal>) || property.PropertyType == typeof(System.Decimal))
if (property.PropertyType == typeof(Nullable<System.Decimal>)
|| property.PropertyType == typeof(System.Decimal) && item.ToString() != "Shared.DTOs.Warehouse.CirculationDto")
{ {
<td> <td>
@decimal.Parse(property.GetValue(item, null).ToString()).ToString("N0") ريال @decimal.Parse(property.GetValue(item, null).ToString()).ToString("N0") ريال
</td> </td>
} }
else if (property.PropertyType == typeof(Nullable<System.Boolean>)
|| property.PropertyType == typeof(System.Boolean))
{
var res = property.GetValue(item, null);
if (res == null)
{
<td>
...
</td>
}
else
{
if (res.ToString().ToLower()=="true")
{
<td>
دارد
</td>
}
else
{
<td>
ندارد
</td>
}
}
}
else if (property.Name.ToLower() == "id" && item.ToString() != "Shared.DTOs.SentTaxDto") else if (property.Name.ToLower() == "id" && item.ToString() != "Shared.DTOs.SentTaxDto")
{ {
if (id > 0) if (id > 0)

View File

@@ -205,6 +205,7 @@
if (result.Status==ComponentStatus.success) if (result.Status==ComponentStatus.success)
{ {
await Load(1); await Load(1);
await modal.HideAsync();
} }
} }
public async Task Item(CirculationDto circulationDto) public async Task Item(CirculationDto circulationDto)

View File

@@ -37,10 +37,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://moadiran.ir:444/api/") }); //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://moadiran.ir:444/api/") });
//Home //Home
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
//farzan //farzan
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir"); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");