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());
}
}
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)
{

View File

@@ -27,7 +27,7 @@ namespace Back.Services.Warehouse
{
var model = new Receipt()
{
Date = item.Date,
Date = item.Date.Replace("/",""),
CODID = item.CODID,
Count = item.Count,
ForSale = item.ForSale,
@@ -60,7 +60,7 @@ namespace Back.Services.Warehouse
public async Task<ReceiptDto?> Update(ReceiptDto item)
{
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.Count= item.Count;
model.ForSale= item.ForSale;

View File

@@ -19,7 +19,7 @@ namespace Back.Services.Warehouse
{
var model = new Remittance()
{
Date = item.Date,
Date = item.Date.Replace("/", ""),
CODID = item.CODID,
Count = item.Count,
info = item.info,
@@ -44,7 +44,7 @@ namespace Back.Services.Warehouse
public async Task<RemittanceDto?> Update(RemittanceDto item)
{
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.Count = item.Count;
model.info = item.info;

View File

@@ -1,4 +1,5 @@
using Back.Common;

using Back.Common;
using Back.Data.Contracts;
using Back.Data.Models.Warehouse;
using Microsoft.EntityFrameworkCore;
@@ -36,7 +37,7 @@ namespace Back.Services.Warehouse
info = s.info,
Type = TypeCirculation.Remittance,
ModelTypeID = (int)s.Type,
ModelTypeTitle = s.Type.GetDisplayName(),
ModelTypeTitle = s.Type.GetEnumDisplayName(),
invoiceID = s.InvoiceID,
});
if (!string.IsNullOrEmpty(date))
@@ -55,24 +56,23 @@ namespace Back.Services.Warehouse
info = s.info,
Type = TypeCirculation.Receipt,
ModelTypeID = (int)s.Type,
ModelTypeTitle = s.Type.GetDisplayName(),
ModelTypeTitle = s.Type.GetEnumDisplayName(),
invoiceID = s.InvoiceID,
ForSale = s.ForSale,
});
if (!string.IsNullOrEmpty(date))
RequestReceipt = RequestReceipt.Where(w => w.Date == date);
if (CODID != 0)
RequestReceipt = RequestReceipt.Where(w => w.CODID == CODID);
try
{
var item = await RequestReceipt.Union(RequestRemittance).OrderByDescending(o => o.Date).ToListAsync();
}
catch (Exception ex)
{
var itemsReceipt = await RequestReceipt.ToListAsync();
var Remittance = await RequestRemittance.ToListAsync();
throw;
}
return await RequestReceipt.Union(RequestRemittance).OrderByDescending(o => o.Date).Paging(PageIndex, PageSize);
return await itemsReceipt.Union(Remittance).OrderByDescending(o => o.Date).Paging(PageIndex, PageSize);
// return await RequestReceipt.Union(RequestRemittance).OrderByDescending(o => o.Date).Paging(PageIndex, PageSize);
//var list = await RequestReceipt.ToListAsync();
//list.AddRange(await RequestRemittance.ToListAsync());
//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)
.Custom((model, context) => {
if (servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
if (!servCOD.ExistCodByCompanyID(model.Item1.CODID, model.Item2).Result)
context.AddFailure("کد کالا یافت نشد");
});

View File

@@ -26,17 +26,11 @@ namespace Back.Validations.Warehouse.Receipt
context.AddFailure("رسید یافت نشد");
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)
{
context.AddFailure("در رسید امکان ویرایش کالا انکان پذیر نیست");
context.AddFailure("در رسید امکان ویرایش کالا امکان پذیر نیست");
}
else
{
@@ -69,7 +63,7 @@ namespace Back.Validations.Warehouse.Receipt
}
}
}
});

View File

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

View File

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

View File

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

View File

@@ -44,12 +44,42 @@
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>
@decimal.Parse(property.GetValue(item, null).ToString()).ToString("N0") ريال
</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")
{
if (id > 0)

View File

@@ -204,7 +204,8 @@
if (result.Status==ComponentStatus.success)
{
await Load(1);
await Load(1);
await modal.HideAsync();
}
}
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/") });
//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
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");