protected void btnAddFooter_OnClick(object sender, ImageClickEventArgs e) { try { var desValue = ((TextBox)gridFactor.FooterRow.Cells[1].Controls[1]).Text; var unitValue = ((DropDownList)gridFactor.FooterRow.Cells[2].Controls[1]).SelectedValue; var countValue = ((TextBox)gridFactor.FooterRow.Cells[3].Controls[1]).Text; //var weightValue = ((TextBox)gridFactor.FooterRow.Cells[4].Controls[1]).Text; var priceValue = ((TextBox)gridFactor.FooterRow.Cells[5].Controls[1]).Text; var fd = new FactorDetail(); fd.RowNumber = ((List <FactorDetail>)Session["GridSource"]).Max(a => a.RowNumber) + 1; fd.Description = desValue; fd.GoodsUnitId = unitValue.ToSafeInt(); fd.Count = countValue.ToSafeDecimal(); //fd.Weight = weightValue.ToSafeDecimal(); fd.Price = priceValue.ToSafeDecimal(); ((List <FactorDetail>)Session["GridSource"]).Add(fd); BindData(); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
protected void btnAddFooter_OnClick(object sender, ImageClickEventArgs e) { try { var dateValue = ((PersianCalender)gridPayment.FooterRow.Cells[1].Controls[1]).Date; var priceValue = ((TextBox)gridPayment.FooterRow.Cells[2].Controls[1]).Text; var typeValue = ((DropDownList)gridPayment.FooterRow.Cells[3].Controls[1]).SelectedValue; var desValue = ((TextBox)gridPayment.FooterRow.Cells[4].Controls[1]).Text; var fd = new PaymentDetail(); fd.RowNumber = ((List <PaymentDetail>)Session["GridSource"]).Max(a => a.RowNumber) + 1; fd.DetailDate = dateValue.ToEnDate(); fd.Price = priceValue.ToSafeDecimal(); fd.PaymentType = typeValue.ToSafeInt(); fd.Description = desValue; ((List <PaymentDetail>)Session["GridSource"]).Add(fd); BindData(); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
public void ProcessRequest(HttpContext context) { try { if (context.Request["id"] == null) { return; } if (!int.TryParse(context.Request["id"], out int id)) { return; } var serializer = new JavaScriptSerializer(); var details = new WorksheetDetailRepository().GetAllDetails(id).ToList(); if (details != null && details.ToList().Any()) { var json = serializer.Serialize(details); context.Response.ContentType = "application/json"; context.Response.Write(json); } } catch (Exception ex) { Debuging.Error(ex.Message + "\r\n" + ex.StackTrace); } }
protected void gridFactor_OnRowUpdating(object sender, GridViewUpdateEventArgs e) { try { var desValue = ((TextBox)gridFactor.Rows[gridFactor.EditIndex].Cells[1].Controls[1]).Text; var unitValue = ((DropDownList)gridFactor.Rows[gridFactor.EditIndex].Cells[2].Controls[1]).SelectedValue; var countValue = ((TextBox)gridFactor.Rows[gridFactor.EditIndex].Cells[3].Controls[1]).Text; //var weightValue = ((TextBox)gridFactor.Rows[gridFactor.EditIndex].Cells[4].Controls[1]).Text; var priceValue = ((TextBox)gridFactor.Rows[gridFactor.EditIndex].Cells[5].Controls[1]).Text; var fd = ((List <FactorDetail>)Session["GridSource"]).SingleOrDefault(a => a.RowNumber == e.RowIndex + 1); fd.Description = desValue; fd.GoodsUnitId = unitValue.ToSafeInt(); fd.Count = countValue.ToSafeDecimal(); //fd.Weight = weightValue.ToSafeDecimal(); fd.Price = priceValue.ToSafeDecimal(); gridFactor.EditIndex = -1; BindData(); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
protected void gridFactor_OnRowUpdating(object sender, GridViewUpdateEventArgs e) { try { var dateValue = ((PersianCalender)gridPayment.Rows[gridPayment.EditIndex].Cells[1].Controls[1]).Date; var priceValue = ((TextBox)gridPayment.Rows[gridPayment.EditIndex].Cells[2].Controls[1]).Text; var typeValue = ((DropDownList)gridPayment.Rows[gridPayment.EditIndex].Cells[3].Controls[1]).SelectedValue; var desValue = ((TextBox)gridPayment.Rows[gridPayment.EditIndex].Cells[4].Controls[1]).Text; var fd = ((List <PaymentDetail>)Session["GridSource"]).SingleOrDefault(a => a.RowNumber == e.RowIndex + 1); fd.DetailDate = dateValue.ToEnDate(); fd.Price = priceValue.ToSafeDecimal(); fd.PaymentType = typeValue.ToSafeInt(); fd.Description = desValue; gridPayment.EditIndex = -1; BindData(); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
protected void gridFactor_OnRowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)) { UpdateTxtTotalPrice(); } } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
//public List<KeyValuePair<int, string>> PaymentTypeList //{ // get // { // var values = Enum.GetValues(typeof (PaymentTypeEnum)).Cast<int>(); // var result = new List<KeyValuePair<int, string>>(); // foreach (int item in values) // { // result.Add(new KeyValuePair<int, string>(item,Enum.GetName(typeof(PaymentTypeEnum),item))); // } // return result; // } //} protected void Page_Load(object sender, EventArgs e) { if (Environment.MachineName.ToLower() == "arash-laptop") { Session["User"] = new BaseRepository <User>().GetById(1); } try { Debuging.Info("Payment->Try to Page_Load"); if (!Page.IsPostBack) { BindDrpFactor(); if (Page.RouteData.Values["Id"].ToSafeInt() != 0) { var paymentId = Page.RouteData.Values["Id"].ToSafeInt(); var paymentRepo = new PaymentRepository(); var payment = paymentRepo.GetById(paymentId); txtDescription.Text = payment.Description; txtPaymentNo.Text = payment.PaymentNo.ToString(); drpFactor.SelectedValue = payment.FactorId.ToString(); drpFactor_OnSelectedIndexChanged(sender, new RadComboBoxSelectedIndexChangedEventArgs("", "", payment.FactorId.ToString(), "")); ucDate.Date = payment.PaymentDate.ToFaDate(); var paymentDetailRepo = new PaymentDetailRepository(); gridPayment.DataSource = Session["GridSource"] = paymentDetailRepo.GetPaymentDetails(paymentId); gridPayment.DataBind(); } else { ucDate.Date = DateTime.Now.ToFaDate(); gridPayment.DataSource = Session["GridSource"] = new List <PaymentDetail>(); gridPayment.DataBind(); txtPaymentNo.Text = (new PaymentRepository().GetMaxPaymentNo() + 1).ToString(); } } } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); } Debuging.Info("Payment->End of Page_Load"); }
protected void Page_Load(object sender, EventArgs e) { try { Debuging.Info("Factor->Try to Page_Load"); if (!Page.IsPostBack) { BindDrpCustomer(); if (Page.RouteData.Values["Id"].ToSafeInt() != 0) { var factorId = Page.RouteData.Values["Id"].ToSafeInt(); var factorRepo = new FactorRepository(); var factor = factorRepo.GetById(factorId); txtFactorNumber.Text = factor.FactorNo.ToString(); txtDescription.Text = factor.Description; drpCustomer.SelectedValue = factor.CustomerId.ToString(); txtDate.Text = factor.FactorDate.ToFaDate(); var factorDetailRepo = new FactorDetailRepository(); gridFactor.DataSource = Session["GridSource"] = factorDetailRepo.GetFactorDetails(factorId); gridFactor.DataBind(); } else { txtDate.Text = DateTime.Now.ToFaDate(); gridFactor.DataSource = Session["GridSource"] = new List <FactorDetail>(); gridFactor.DataBind(); txtFactorNumber.Text = (new FactorRepository().GetMaxFactorNo() + 1).ToString(); } //BindFooterGoodsUnitDrp(); } } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); } Debuging.Info("Factor->End of Page_Load"); }
protected void Application_Error(object sender, EventArgs e) { Exception exc = Server.GetLastError(); Debuging.Error(exc.Message); // For other kinds of errors give the user some information // but stay on the default page Response.Write("<div dir=\"rtl\" style=\"padding: 20px;font-family=Iransans;color:red;font-weight:bold;\"><h2>متاسفانه خطایی در سیستم روی داده است</h2>\n"); Response.Write( "<p>" + exc.Message + "<br/>" + exc.InnerException != null ? exc.InnerException.Message : "" + "<br/>" + exc.InnerException?.InnerException != null ? exc.InnerException?.InnerException?.Message : "" + "</p>\n"); Response.Write("</br/> بازگشت به <a href='Home.aspx'>" + "صفحه اصلی</a></div>\n"); // Clear the error from the server Server.ClearError(); }
protected void btnAddFirstRow_OnClick(object sender, ImageClickEventArgs e) { try { var newRow = new PaymentDetail(); newRow.RowNumber = 1; var source = new List <PaymentDetail>(); source.Add(newRow); Session["GridSource"] = source; gridPayment.EditIndex = 0; BindData(); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
protected void gridFactor_OnRowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)) { var count = ((Label)e.Row.Cells[3].Controls[1]).Text.ToSafeDecimal(); //count var price = ((Label)e.Row.Cells[5].Controls[1]).Text.ToSafeDecimal(); //price ((Label)e.Row.Cells[6].Controls[1]).Text = (count * price).ToString("N0"); //((Label)gridFactor.FooterRow.Cells[6].Controls[1]).Text = fds.Sum(a => a.Count * a.Price).ToSafeString().ToFaGString(); UpdateTxtTotalPrice(); } } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
private void BindDrpCustomer() { try { var repo = new CustomerRepository(); var source = repo.GetAll(); var customer = new Repository.Entity.Domain.Customer(); customer.Id = -1; customer.Name = "انتخاب کنید..."; source.Insert(0, customer); drpCustomer.DataSource = source; drpCustomer.DataValueField = "Id"; drpCustomer.DataTextField = "Name"; drpCustomer.DataBind(); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); } }
protected void btnAddFirstRow_OnClick(object sender, ImageClickEventArgs e) { try { var newRow = new FactorDetail(); newRow.RowNumber = 1; var source = new List <FactorDetail>(); source.Add(newRow); Session["GridSource"] = source; gridFactor.EditIndex = 0; BindData(); //((TextBox)gridFactor.Rows[gridFactor.EditIndex].Cells[1].Controls[1]).Focus(); //BindFooterGoodsUnitDrp(); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
protected string GetUploadAllowedFileExtensions() { string result = ""; try { string[] extsWithoutDot = new string[asyncUploadPic.AllowedFileExtensions.Count()]; for (int i = 0; i < asyncUploadPic.AllowedFileExtensions.Count(); i++) { var withoutDot = asyncUploadPic.AllowedFileExtensions[i].Replace(".", ""); extsWithoutDot[i] = withoutDot; } result = String.Join(" , ", extsWithoutDot); } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); } return(result); }
public static string AddRow(string input) { //WID,OperatorID,ProcessID var parts = input.Replace('و', ',').Split(','); var worksheetId = parts[0].ToSafeInt(); var operatorId = parts[1].ToSafeInt(); var processId = parts[2].ToSafeInt(); var workLinerepo = new WorkLineRepository(); var thisWorksheetWorkLines = workLinerepo.Get(a => a.WorksheetId == worksheetId); var prevProcessOfThisWorksheet = thisWorksheetWorkLines.Any() ? thisWorksheetWorkLines.Where(a => a.ProcessId != 999).Max(a => a.ProcessId) : 0; if (prevProcessOfThisWorksheet != 999) { if (thisWorksheetWorkLines != null && thisWorksheetWorkLines.Any()) { if (prevProcessOfThisWorksheet != 0 && prevProcessOfThisWorksheet >= processId) { return("عدم رعایت ترتیب فرآیند" + "- کاربر:" + new UserRepository().GetById(operatorId)?.Username + "- کاربرگ:" + worksheetId); } } } if (HttpContext.Current.Session["worksheetProcesses" + "#" + worksheetId] == null) { var wsheetProcesses = new WorksheetRepository().GetWorksheetProcesses(worksheetId); if (wsheetProcesses == null) { return("کاربرگ ردیف ندارد"); } HttpContext.Current.Session["worksheetProcesses" + "#" + worksheetId] = wsheetProcesses; } var thisWorksheetProcesses = (List <int>)HttpContext.Current.Session["worksheetProcesses" + "#" + worksheetId]; var indexOfPrevProcess = thisWorksheetProcesses.IndexOf(prevProcessOfThisWorksheet); var indexOfNextProcess = indexOfPrevProcess + 1; var nextProcessOfThisWorksheet = thisWorksheetProcesses[indexOfNextProcess]; if (processId != 999 && processId != nextProcessOfThisWorksheet) { return("عدم رعایت ترتیب فرآیند" + "- کاربر:" + new UserRepository().GetById(operatorId)?.Username + "- کاربرگ:" + worksheetId); } var uow = new UnitOfWork(); uow.WorkLines.Create(new Repository.Entity.Domain.WorkLine() { InsertDateTime = DateTime.Now, WorksheetId = worksheetId, OperatorId = operatorId, //ProductId = productId, ProcessId = processId } ); var result = uow.SaveChanges(); if (result.IsSuccess) { HttpContext.Current.Session[worksheetId + "#" + operatorId] = processId; return("OK"); } else { //((Main)Page.Master).SetGeneralMessage("خطا در ذخیره اطلاعات", MessageType.Error); Debuging.Error(result.ResultCode + "," + result.Message + "," + result.Message); return("خطا در اضافه کردن ردیف"); } }
public static string Save(int userId, string date, int id, Repository.Entity.Domain.Worksheet model) { if (model == null) { //((Main)Page.Master).SetGeneralMessage("اطلاعاتی برای ذخیره کردن یافت نشد", MessageType.Error); return("اطلاعاتی برای ذخیره کردن یافت نشد"); } if (!model.WorksheetDetails.Any()) { return("هیچ ردیفی ثبت نشده است"); } //if(model.WorksheetDetails.GroupBy(a=>a.ProductId).Where(a => a.Count() > 1).Count()>0) // return "ردیف با کالای تکراری ثبت شده است"; var uow = new UnitOfWork(); if (model.WorksheetDetails.GroupBy(a => a.ACode).Where(a => a.Count() > 1).Any()) { return("شناسه کالای تکراری در ردیف ها"); } if (id.ToSafeInt() == 0) { var w = new Repository.Entity.Domain.Worksheet(); var insDateTime = model.InsertDateTime; w.Date = Utility.AdjustTimeOfDate(date.ToEnDate()); w.PartNo = model.PartNo; w.WaxNo = model.WaxNo; w.InsertDateTime = insDateTime; w.OperatorId = model.OperatorId; w.ColorId = model.ColorId; w.UserId = userId; w.Status = -1; w.WorksheetDetails = model.WorksheetDetails; w.Desc = model.Desc; uow.Worksheets.Create(w); } else { var tobeEdited = uow.Worksheets.GetById(id.ToSafeInt()); uow.WorksheetDetails.Delete(a => a.WorksheetId == tobeEdited.Id); tobeEdited.UpdateDateTime = DateTime.Now; tobeEdited.Date = Utility.AdjustTimeOfDate(date.ToEnDate()); tobeEdited.OperatorId = model.OperatorId; tobeEdited.UserId = userId; tobeEdited.ColorId = model.ColorId; tobeEdited.PartNo = model.PartNo; tobeEdited.WaxNo = model.WaxNo; tobeEdited.Desc = model.Desc; if (tobeEdited.OperatorId != model.OperatorId) { var workLineRepo = new WorkLineRepository(); if (workLineRepo.Get(a => a.WorksheetId == tobeEdited.Id).Any()) { return("برای این کاربرگ در صف تولید دیتا ثبت شده و اوپراتور آن قابل تغییر نیست"); } } foreach (WorksheetDetail item in model.WorksheetDetails) { uow.WorksheetDetails.Create(new WorksheetDetail() { Status = -1, ProductId = item.ProductId, UpdateDateTime = DateTime.Now, WorksheetId = tobeEdited.Id, ACode = item.ACode }); } } var result = uow.SaveChanges(); if (result.IsSuccess) { //RedirectToWorksheetListActionResultWithMessage(); return("OK"); } else { //((Main)Page.Master).SetGeneralMessage("خطا در ذخیره اطلاعات", MessageType.Error); Debuging.Error(result.ResultCode + "," + result.Message + "," + result.Message); return("خطا در ذخیره اطلاعات"); } }
protected void btnSave_Click(object sender, EventArgs e) { try { if (!ValidateData()) { return; } if (Page.RouteData.Values["Id"].ToSafeInt() == 0) { var uow = new UnitOfWork(); var payment = new Repository.Entity.Domain.Payment(); payment.PaymentNo = txtPaymentNo.Text.ToSafeInt(); payment.FactorId = drpFactor.SelectedValue.ToSafeInt(); payment.InsertDateTime = DateTime.Now; payment.PaymentDate = ucDate.Date.ToEnDate(); payment.Description = txtDescription.Text; var fd = ((List <PaymentDetail>)Session["GridSource"]); payment.TotalPrice = fd.Sum(a => a.Price); payment.PaymentDetails = fd; uow.Payments.Create(payment); var result = uow.SaveChanges(); if (result.IsSuccess) { RedirectPaymentListActionResultWithMessage(); } else { Debuging.Error(MethodBase.GetCurrentMethod().Name + "->" + result.ResultMessage); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } } else { var uow = new UnitOfWork(); var toBeEditedPayment = uow.Payments.Find(Page.RouteData.Values["Id"].ToSafeInt()); toBeEditedPayment.PaymentNo = txtPaymentNo.Text.ToSafeInt(); toBeEditedPayment.FactorId = drpFactor.SelectedValue.ToSafeInt(); toBeEditedPayment.UpdateDateTime = DateTime.Now; //toBeEditedPayment.FactorDate = txtDate.Text.ToEnDate(); toBeEditedPayment.Description = txtDescription.Text; toBeEditedPayment.PaymentDate = ucDate.Date.ToEnDate(); var pd = ((List <PaymentDetail>)Session["GridSource"]); toBeEditedPayment.TotalPrice = pd.Sum(a => a.Price); toBeEditedPayment.PaymentDetails = pd; var oldPdIds = new PaymentDetailRepository().GetPaymentDetails(toBeEditedPayment.Id).Select(a => a.Id); uow.PaymentDetails.Delete(a => oldPdIds.Contains(a.Id)); var result = uow.SaveChanges(); if (result.IsSuccess) { RedirectPaymentListActionResultWithMessage(); } else { Debuging.Error(MethodBase.GetCurrentMethod().Name + "->" + result.ResultMessage); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } } } catch (Exception ex) { Debuging.Error(ex, MethodBase.GetCurrentMethod().Name); ShowErrorMsg(MessageText.UNKNOWN_ERROR); } }
protected void btnSave_OnClick(object sender, EventArgs e) { var source = (List <InputHelper>)Session["GridSource"]; if (source.Count == 0) { ((Main)Page.Master).SetGeneralMessage("اطلاعاتی برای ذخیره کردن یافت نشد", MessageType.Error); return; } var uow = new UnitOfWork(); if (Page.RouteData.Values["Id"].ToSafeInt() == 0) { var io = new Repository.Entity.Domain.InputOutput(); if (divReceiptId.Visible) { io.ReceiptId = txtInReceiptId.Text.ToSafeInt(); } var insDateTime = Utility.AdjustTimeOfDate(dtInputOutput.Date.ToEnDate()); io.InsertDateTime = insDateTime; io.UserId = ((User)Session["User"]).Id; io.Status = -1; io.InOutType = Page.RouteData.Values["Type"].ToSafeString() == "In" ? (int)InOutType.In : (int)InOutType.Out; io.InputOutputDetails = CastToIODetail((List <InputHelper>)Session["GridSource"]); uow.InputOutputs.Create(io); } else { var tobeEdited = uow.InputOutputs.GetById(Page.RouteData.Values["Id"].ToSafeInt()); if (divReceiptId.Visible) { tobeEdited.ReceiptId = txtInReceiptId.Text.ToSafeInt(); } uow.InputOutputDetails.Delete(a => a.InputOutputId == tobeEdited.Id); tobeEdited.InsertDateTime = Utility.AdjustTimeOfDate(dtInputOutput.Date.ToEnDate()); foreach (InputHelper item in source) { uow.InputOutputDetails.Create(new InputOutputDetail() { Count = item.Count, CustomerId = item.CustomerId, InsertDateTime = Utility.AdjustTimeOfDate(item.InsertDateTime.ToEnDate()), Status = -1, ProductId = item.ProductId, UpdateDateTime = DateTime.Now, InputOutputId = tobeEdited.Id, ProductionQuality = item.ProductionQualityId }); } } var result = uow.SaveChanges(); if (result.IsSuccess) { RedirectFactorListActionResultWithMessage(); } else { ((Main)Page.Master).SetGeneralMessage("خطا در ذخیره اطلاعات", MessageType.Error); Debuging.Error(result.Message); } }
public static string AddRow(string input, string reworkACodes, string reworkReasons, string reworkDesc, string reworkEsghatMode, string reworkEsghatPrevProcessId) { //WID,OperatorID,ProcessID var parts = input.Replace('و', ',').Split(','); var worksheetId = parts[0].ToSafeInt(); var operatorId = parts[1].ToSafeInt(); var processId = parts[2].Replace("#", "").ToSafeInt(); var workLinerepo = new WorkLineRepository(); var thisWorksheetWorkLines = workLinerepo.Get(a => a.WorksheetId == worksheetId); var prevProcessIsEsghat = thisWorksheetWorkLines.Any() ? thisWorksheetWorkLines.Any(a => a.ProcessId == 1001) : false; if (prevProcessIsEsghat) { return("پس از اسقاط قادر به ثبت فرآیند دیگری نیستید"); } var actualPrevProcess = thisWorksheetWorkLines.Any() ? thisWorksheetWorkLines.OrderByDescending(a => a.Id).FirstOrDefault().ProcessId : 0; //var breforePrevProcessOfThisWorksheet = thisWorksheetWorkLines.Any() ? thisWorksheetWorkLines.Where(a=>a.ProcessId != 999 && a.ProcessId != 1000 && a.ProcessId != 1001 && a.ProcessId != 1002).Max(a => a.ProcessId) : 0; var prevProcessOfThisWorksheet = thisWorksheetWorkLines.Any() ? thisWorksheetWorkLines.Where(a => a.ProcessId != 999 && a.ProcessId != 1000 && a.ProcessId != 1001 && a.ProcessId != 1002).Max(a => a.ProcessId) : 0; if (actualPrevProcess == 1002 && prevProcessOfThisWorksheet == processId) { //after launch previous process can be continued } else if (processId != 1000 && processId != 1001 && processId != 1002) { if (thisWorksheetWorkLines != null && thisWorksheetWorkLines.Any()) { if (prevProcessOfThisWorksheet != 0 && prevProcessOfThisWorksheet >= processId) { return("عدم رعایت ترتیب فرآیند" + "- کاربر:" + new UserRepository().GetById(operatorId)?.Username + "- کاربرگ:" + worksheetId); } } } if (HttpContext.Current.Session["worksheetProcesses" + "#" + worksheetId] == null) { var wsheetProcesses = new WorksheetRepository().GetWorksheetProcesses(worksheetId); if (wsheetProcesses == null) { return("کاربرگ ردیف ندارد"); } HttpContext.Current.Session["worksheetProcesses" + "#" + worksheetId] = wsheetProcesses; } if (processId != 999 && processId != 1000 && processId != 1001 && processId != 1002) // 999 etmame movaghat, 1000 rework, 1001 esghat,1002 nahar { var thisWorksheetProcesses = (List <int>)HttpContext.Current.Session["worksheetProcesses" + "#" + worksheetId]; var indexOfPrevProcess = thisWorksheetProcesses.IndexOf(prevProcessOfThisWorksheet); var indexOfNextProcess = indexOfPrevProcess + 1; var nextProcessOfThisWorksheet = thisWorksheetProcesses[indexOfNextProcess]; if (processId != nextProcessOfThisWorksheet && !(actualPrevProcess == 1002 && prevProcessOfThisWorksheet == processId)) { return("عدم رعایت ترتیب فرآیند" + "- کاربر:" + new UserRepository().GetById(operatorId)?.Username + "- کاربرگ:" + worksheetId); } } var uow = new UnitOfWork(); if (processId != 999 && processId != 1000 && processId != 1001) { var wl = uow.WorkLines.Get(a => a.WorksheetId == worksheetId && a.OperatorId == operatorId && a.ProcessId == processId); if (wl?.Count != 0 && !(actualPrevProcess == 1002 && prevProcessOfThisWorksheet == processId)) { return($"فرآیند با این مشخصات قبلا ثبت شده کاربر:{new UserRepository().GetById(operatorId)?.Username} "); } } else { var intReworkEsghatPrevProcessId = reworkEsghatPrevProcessId.ToSafeInt(); if (processId == 1000) { var rw = uow.Reworks.Get(a => a.WorksheetId == worksheetId && a.PrevProcessId == intReworkEsghatPrevProcessId); if (rw?.Count != 0) { return("برای این فرآیند قبلا دوباره کاری ثبت شده است"); } } else if (processId == 1001) { var rw = uow.Esghats.Get(a => a.WorksheetId == worksheetId && a.PrevProcessId == intReworkEsghatPrevProcessId); if (rw?.Count != 0) { return("برای این فرآیند قبلا اسقاط ثبت شده است"); } } } var newWorkLine = uow.WorkLines.Create(new Repository.Entity.Domain.WorkLine() { InsertDateTime = DateTime.Now, WorksheetId = worksheetId, OperatorId = operatorId, ProcessId = processId } ); var acodes = reworkACodes.Split(','); var reasons = reworkReasons.Split(','); if (acodes.Contains("-1")) { return("علت انتخاب نشده"); } if (reworkEsghatMode != "") { if (reworkEsghatMode.ToLower() == "rework") { var newRework = uow.Reworks.Create(new Repository.Entity.Domain.Rework() { InsertDateTime = DateTime.Now, OperatorId = operatorId, InsertedUserId = operatorId, //? Desc = reworkDesc, PrevProcessId = reworkEsghatPrevProcessId.ToSafeInt(), WorksheetId = worksheetId, Status = -1, }); if (acodes.Any()) { newRework.ReworkDetails = new List <ReworkDetail>(); for (int i = 0; i < acodes.Length; i++) { newRework.ReworkDetails.Add(new ReworkDetail { ACode = acodes[i], ReworkReasonId = reasons[i].ToSafeInt() }); } } newWorkLine.Rework = newRework; } else { var newEsghat = uow.Esghats.Create(new Repository.Entity.Domain.Esghat() { InsertDateTime = DateTime.Now, OperatorId = operatorId, InsertedUserId = operatorId, //? Desc = reworkDesc, PrevProcessId = reworkEsghatPrevProcessId.ToSafeInt(), WorksheetId = worksheetId, Status = -1 }); if (acodes.Any()) { newEsghat.EsghatDetails = new List <EsghatDetail>(); for (int i = 0; i < acodes.Length; i++) { newEsghat.EsghatDetails.Add(new EsghatDetail { ACode = acodes[i], ReworkReasonId = reasons[i].ToSafeInt() }); } } newWorkLine.Esghat = newEsghat; } } var result = uow.SaveChanges(); if (result.IsSuccess) { HttpContext.Current.Session[worksheetId + "#" + operatorId] = processId; return("OK"); } else { //((Main)Page.Master).SetGeneralMessage("خطا در ذخیره اطلاعات", MessageType.Error); Debuging.Error(result.ResultCode + "," + result.Message + "," + result.Message); return("خطا در اضافه کردن ردیف"); } }