/// <summary> /// Insert a AssemblySiteInventory. /// </summary> public void Insert(Model.AssemblySiteInventory assemblySiteInventory) { // // todo:add other logic here // try { BL.V.BeginTransaction(); this.Validate(assemblySiteInventory); this.TiGuiExists(assemblySiteInventory); assemblySiteInventory.InsertTime = DateTime.Now; assemblySiteInventory.UpdateTime = DateTime.Now; string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, DateTime.Now.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, DateTime.Now.Year, DateTime.Now.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, DateTime.Now.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(assemblySiteInventory); foreach (var item in assemblySiteInventory.Details) { item.AssemblySiteInventoryId = assemblySiteInventory.AssemblySiteInventoryId; //防止ID变更后不同 detailaccessor.Insert(item); } BL.V.CommitTransaction(); } catch (Exception ex) { BL.V.RollbackTransaction(); throw ex; } }
/// <summary> /// Insert a ANSIPCImpactCheck. /// </summary> public void Insert(Model.ANSIPCImpactCheck aNSIPCImpactCheck) { Validate(aNSIPCImpactCheck); if (this.IsExistsPNTForInsert(aNSIPCImpactCheck.PronoteHeaderId, aNSIPCImpactCheck.ForANSIOrJIS)) { throw new Helper.MessageValueException("此加工單已生成對應的測試單,請勿重複生成!"); } try { BL.V.BeginTransaction(); aNSIPCImpactCheck.InsertTime = DateTime.Now; aNSIPCImpactCheck.UpdateTime = DateTime.Now; TiGuiExists(aNSIPCImpactCheck); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, aNSIPCImpactCheck.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, aNSIPCImpactCheck.InsertTime.Value.Year, aNSIPCImpactCheck.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, aNSIPCImpactCheck.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(aNSIPCImpactCheck); foreach (Model.ANSIPCImpactCheckDetail detail in aNSIPCImpactCheck.Details) { detail.ANSIPCImpactCheckID = aNSIPCImpactCheck.ANSIPCImpactCheckID; ANSIpcicDetailManager.Insert(detail); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public void Insert(Model.WorkHouse workHouse) { Validate(workHouse); workHouse.InsertTime = DateTime.Now; workHouse.UpdateTime = DateTime.Now; workHouse.WorkHouseId = Guid.NewGuid().ToString(); TiGuiExists(workHouse); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, workHouse.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, workHouse.InsertTime.Value.Year, workHouse.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, workHouse.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(workHouse); }
/// <summary> /// Insert a AcOtherShouldCollection. /// </summary> public void Insert(Model.AcOtherShouldCollection acOtherShouldCollection) { // // todo:add other logic here // Validate(acOtherShouldCollection); try { acOtherShouldCollection.InsertTime = DateTime.Now; BL.V.BeginTransaction(); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, acOtherShouldCollection.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, acOtherShouldCollection.InsertTime.Value.Year, acOtherShouldCollection.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, acOtherShouldCollection.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(acOtherShouldCollection); foreach (Model.AcOtherShouldCollectionDetail acOtherShouldCollectionDetail in acOtherShouldCollection.Details) { acOtherShouldCollectionDetail.AcOtherShouldCollectionDetailId = Guid.NewGuid().ToString(); acOtherShouldCollectionDetail.AcOtherShouldCollectionId = acOtherShouldCollection.AcOtherShouldCollectionId; AcOtherShouldCollectionDetailAccessor.Insert(acOtherShouldCollectionDetail); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public string GetIdSimple(DateTime dt) { string settingId = this.GetSettingId(); string invoiceKind = this.GetInvoiceKind().ToLower(); DateTime datetime = dt; if (string.IsNullOrEmpty(invoiceKind) || string.IsNullOrEmpty(settingId)) { return(string.Empty); } string rule = Settings.Get(settingId); if (string.IsNullOrEmpty(rule)) { return(string.Empty); } string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, datetime.ToString("yyyy-MM-dd")); string sequencekey = sequencekey_d; int sequenceval = SequenceManager.GetCurrentVal(sequencekey); int a = sequenceval; sequenceval++; string d2 = string.Format("{0:d2}", datetime.Day); string m2 = string.Format("{0:d2}", datetime.Month); string y2 = string.Format("{0:d2}", datetime.Year).Substring(2, 2); string y4 = string.Format("{0:d4}", datetime.Year); string n1 = string.Format("{0:d1}", sequenceval); string n2 = string.Format("{0:d2}", sequenceval); string n3 = string.Format("{0:d3}", sequenceval); string n4 = string.Format("{0:d4}", sequenceval); return(rule.Replace("{D2}", d2).Replace("{M2}", m2).Replace("{Y2}", y2).Replace("{Y4}", y4).Replace("{N}", n4).Replace("{N1}", n1).Replace("{N2}", n2).Replace("{N3}", n3).Replace("{N4}", n4)); }
/// <summary> /// Insert a PCOtherCheck. /// </summary> public void Insert(Model.PCOtherCheck pCOtherCheck) { Validate(pCOtherCheck); try { BL.V.BeginTransaction(); TiGuiExists(pCOtherCheck); pCOtherCheck.InsertTime = DateTime.Now; pCOtherCheck.UpdateTime = DateTime.Now; string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, pCOtherCheck.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, pCOtherCheck.InsertTime.Value.Year, pCOtherCheck.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, pCOtherCheck.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(pCOtherCheck); foreach (Model.PCOtherCheckDetail PcotherCheckDetail in pCOtherCheck.Detail) { if (PcotherCheckDetail.Product == null || string.IsNullOrEmpty(PcotherCheckDetail.Product.ProductId)) { continue; } PcotherCheckDetail.PCOtherCheckId = pCOtherCheck.PCOtherCheckId; PCOtherCheckDetailAccessor.Insert(PcotherCheckDetail); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public void Insert(Model.ThicknessTest thicknessTest) { Validate(thicknessTest); try { BL.V.BeginTransaction(); thicknessTest.InsertTime = DateTime.Now; thicknessTest.UpdateTime = DateTime.Now; TiGuiExists(thicknessTest); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, thicknessTest.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, thicknessTest.InsertTime.Value.Year, thicknessTest.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, thicknessTest.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(thicknessTest); foreach (Model.ThicknessTestDetails d in thicknessTest.Details) { d.ThicknessTestId = thicknessTest.ThicknessTestId; detailManager.Insert(d); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public void Insert(Model.PCFogCheck pCFogCheck) { Validate(pCFogCheck); try { BL.V.BeginTransaction(); pCFogCheck.InsertTime = DateTime.Now; pCFogCheck.UpdateTime = DateTime.Now; TiGuiExists(pCFogCheck); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, pCFogCheck.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, pCFogCheck.InsertTime.Value.Year, pCFogCheck.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, pCFogCheck.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(pCFogCheck); foreach (Model.PCFogCheckDetail d in pCFogCheck.Details) { d.PCFogCheckId = pCFogCheck.PCFogCheckId; new PCFogCheckDetailManager().Insert(d); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a PCEarProtectCheck. /// </summary> public void Insert(Model.PCEarProtectCheck pCEarProtectCheck) { // // todo:add other logic here // Validate(pCEarProtectCheck); try { BL.V.BeginTransaction(); pCEarProtectCheck.InsertTime = DateTime.Now; pCEarProtectCheck.UpdateTime = DateTime.Now; TiGuiExists(pCEarProtectCheck); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, pCEarProtectCheck.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, pCEarProtectCheck.InsertTime.Value.Year, pCEarProtectCheck.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, pCEarProtectCheck.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(pCEarProtectCheck); foreach (var item in pCEarProtectCheck.Details) { Detailaccessor.Insert(item); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a BGHandbook. /// </summary> public void Insert(Model.BGHandbook bGHandbook) { // // todo:add other logic here // bGHandbook.InsertTime = DateTime.Now; TiGuiExists(bGHandbook); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, bGHandbook.BGHandbookDate.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, bGHandbook.BGHandbookDate.Value.Year, bGHandbook.BGHandbookDate.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, bGHandbook.BGHandbookDate.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(bGHandbook); addDetail(bGHandbook); }
/// <summary> /// Insert a ProduceStatistics. /// </summary> public void Insert(Model.ProduceStatistics produceStatistics) { // // todo:add other logic here // Validate(produceStatistics); try { produceStatistics.InsertTime = DateTime.Now; produceStatistics.UpdateTime = DateTime.Now; BL.V.BeginTransaction(); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, produceStatistics.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, produceStatistics.InsertTime.Value.Year, produceStatistics.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, produceStatistics.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(produceStatistics); foreach (Model.ProduceStatisticsDetail produceStatisticsDetail in produceStatistics.Details) { produceStatisticsDetail.ProduceStatisticsId = produceStatistics.ProduceStatisticsId; ProduceStatisticsDetailAccessor.Insert(produceStatisticsDetail); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a PCSamplingEar. /// </summary> public void Insert(Model.PCSamplingEar PCSamplingEar) { // // todo:add other logic here // try { BL.V.BeginTransaction(); this.Validate(PCSamplingEar); PCSamplingEar.InsertTime = DateTime.Now; PCSamplingEar.UpdateTime = DateTime.Now; this.TiGuiExists(PCSamplingEar); accessor.Insert(PCSamplingEar); foreach (var item in PCSamplingEar.Details) { item.PCSamplingEarId = PCSamplingEar.PCSamplingEarId; accessorDetail.Insert(item); } string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, PCSamplingEar.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, PCSamplingEar.InsertTime.Value.Year, PCSamplingEar.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, PCSamplingEar.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public void Insert(Model.AtParameterSet atParameterSet) { Validate(atParameterSet); try { BL.V.BeginTransaction(); atParameterSet.InsertTime = DateTime.Now; atParameterSet.UpdateTime = DateTime.Now; TiGuiExists(atParameterSet); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, atParameterSet.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, atParameterSet.InsertTime.Value.Year, atParameterSet.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, atParameterSet.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); if (atParameterSet.IsThisYear.Value) { this.UpdateIsThisYear(atParameterSet.AtParameterSetId); } accessor.Insert(atParameterSet); BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a ANSIPCImpactCheck. /// </summary> public void Insert(Model.ANSIPCImpactCheck aNSIPCImpactCheck) { Validate(aNSIPCImpactCheck); try { BL.V.BeginTransaction(); aNSIPCImpactCheck.InsertTime = DateTime.Now; aNSIPCImpactCheck.UpdateTime = DateTime.Now; TiGuiExists(aNSIPCImpactCheck); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, aNSIPCImpactCheck.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, aNSIPCImpactCheck.InsertTime.Value.Year, aNSIPCImpactCheck.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, aNSIPCImpactCheck.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(aNSIPCImpactCheck); foreach (Model.ANSIPCImpactCheckDetail detail in aNSIPCImpactCheck.Details) { detail.ANSIPCImpactCheckID = aNSIPCImpactCheck.ANSIPCImpactCheckID; ANSIpcicDetailManager.Insert(detail); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Delete ProduceOtherReturnMaterial by primary key. /// </summary> public void Delete(string produceOtherReturnMaterialId) { // // todo:add other logic here // try { BL.V.BeginTransaction(); Model.ProduceOtherReturnMaterial model = this.Get(produceOtherReturnMaterialId); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, model.InsertTime.Value.ToString("yyyy-MM-dd")); SequenceManager.Decrement(sequencekey_d); CancelAffect(accessor.Get(produceOtherReturnMaterialId)); accessor.Delete(produceOtherReturnMaterialId); BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a ProductScrap. /// </summary> public void Insert(Model.ProductScrap productScrap) { // // todo:add other logic here // try { BL.V.BeginTransaction(); Validate(productScrap); productScrap.InsertTime = DateTime.Now; productScrap.UpdateTime = DateTime.Now; TiGuiExists(productScrap); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, productScrap.InsertTime.Value.ToString("yyyy-MM-dd")); SequenceManager.Increment(sequencekey_d); accessor.Insert(productScrap); foreach (var item in productScrap.Details) { accessorDetail.Insert(item); accessorStock.Decrement(new BL.DepotPositionManager().Get(item.DepotPositionId), item.Product, Convert.ToDouble(item.ScrapQuantity)); accessorProduct.UpdateProduct_Stock(item.Product); } BL.V.CommitTransaction(); } catch (Exception ex) { BL.V.RollbackTransaction(); throw ex; } }
/// <summary> /// Insert a Customer. /// </summary> public void Insert(Model.Customer customer) { // // todo:add other logic here // Validate(customer); if (this.Exists(customer.Id)) { throw new Helper.InvalidValueException(Model.Customer.PRO_Id); } try { V.BeginTransaction(); //设置KEY值 SequenceManager.Increment("customer"); if (customer.AreaCategory != null) { customer.AreaCategoryId = customer.AreaCategory.AreaCategoryId; } if (customer.TradeCategory != null) { customer.TradeCategoryId = customer.TradeCategory.TradeCategoryId; } if (customer.CustomerCategory != null) { customer.CustomerCategoryId = customer.CustomerCategory.CustomerCategoryId; } customer.InsertTime = DateTime.Now; customer.CustomerId = Guid.NewGuid().ToString(); accessor.Insert(customer); foreach (Model.CustomerContact contact in customer.Contacts) { contact.Customer = customer; contact.CustomerId = customer.CustomerId; if (string.IsNullOrEmpty(contact.CustomerContactId)) { contact.CustomerContactId = Guid.NewGuid().ToString(); } customerContactAccessor.Insert(contact); } //foreach (Model.CustomerMarks mark in customer.Marks) //{ // mark.CustomerId = customer.CustomerId; // (new BL.CustomerMarksManager()).Insert(mark); //} V.CommitTransaction(); } catch (Exception ex) { V.RollbackTransaction(); throw ex; } }
/// <summary> /// Insert a TechonlogyHeader. /// </summary> public void Insert(Model.TechonlogyHeader techonlogyHeader) { // // todo:add other logic here // Validate(techonlogyHeader); if (this.Exists(techonlogyHeader.Id)) { //throw new Helper.InvalidValueException(Model.Product.PRO_Id); techonlogyHeader.Id = this.GetId(DateTime.Now); } //if (this.Exists(techonlogyHeader.Id)) //{ // throw new Helper.InvalidValueException(Model.TechonlogyHeader.PROPERTY_ID); //} try { techonlogyHeader.InsertTime = DateTime.Now; techonlogyHeader.UpdateTime = DateTime.Now; string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, techonlogyHeader.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, techonlogyHeader.InsertTime.Value.Year, techonlogyHeader.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, techonlogyHeader.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); IList <string> str = new List <string>(); foreach (Model.Technologydetails detail in techonlogyHeader.detail) { if (detail.TechnologydetailsNo == null) { continue; } if (str.Contains(detail.TechnologydetailsNo)) { throw new Helper.InvalidValueException(Model.Technologydetails.PROPERTY_TECHNOLOGYDETAILSNO); } str.Add(detail.TechnologydetailsNo); } BL.V.BeginTransaction(); //techonlogyHeader.TechonlogyHeaderId = GetNewId(); accessor.Insert(techonlogyHeader); foreach (Model.Technologydetails detail in techonlogyHeader.detail) { if (string.IsNullOrEmpty(detail.ProceduresId)) { continue; } if (string.IsNullOrEmpty(detail.TechnologydetailsNo)) { throw new Helper.RequireValueException(Model.Technologydetails.PROPERTY_TECHNOLOGYDETAILSNO); } //if (accessorDetails.IsExists_TechnologydetailsNo(detail)) // throw new Helper.InvalidValueException(Model.Technologydetails.PROPERTY_TECHNOLOGYDETAILSNO); detail.TechonlogyHeaderId = techonlogyHeader.TechonlogyHeaderId; accessorDetails.Insert(detail); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public void InsertWithOutTrans(Model.PronoteHeader pronoteHeader) { pronoteHeader.InsertTime = DateTime.Now; pronoteHeader.UpdateTime = DateTime.Now; TiGuiExists(pronoteHeader); if (pronoteHeader.Employee0 != null) { pronoteHeader.Employee0Id = pronoteHeader.Employee0.EmployeeId; } if (pronoteHeader.Employee1 != null) { pronoteHeader.Employee1Id = pronoteHeader.Employee1.EmployeeId; } if (pronoteHeader.Employee2 != null) { pronoteHeader.Employee2Id = pronoteHeader.Employee2.EmployeeId; } string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, pronoteHeader.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, pronoteHeader.InsertTime.Value.Year, pronoteHeader.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, pronoteHeader.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); pronoteHeader.InvoiceStatus = 1; pronoteHeader.InDepotQuantity = 0; pronoteHeader.IsClose = false; accessor.Insert(pronoteHeader); Model.MRSdetails mrsDal = mRSdetailsManager.Get(pronoteHeader.MRSdetailsId); if (mrsDal != null) { if (mrsDal.MRSHasSingleSum == null) { mrsDal.MRSHasSingleSum = 0; } mrsDal.MRSHasSingleSum += pronoteHeader.DetailsSum; if (mrsDal.MRSHasSingleSum >= mrsDal.MRSdetailssum) { mrsDal.DetailsFlag = 2; } else { if (mrsDal.MRSHasSingleSum > 0) { mrsDal.DetailsFlag = 1; } else { mrsDal.DetailsFlag = 0; } } mrsDal.ArrangeDesc = "已經排單"; mRSdetailsManager.Update(mrsDal); UpdateMRSHeaderFlag(mrsDal.MRSHeader); } foreach (Model.PronotedetailsMaterial proMaterial in pronoteHeader.DetailsMaterial) { if (string.IsNullOrEmpty(proMaterial.ProductId)) { continue; } proMaterial.PronoteHeaderID = pronoteHeader.PronoteHeaderID; PronotedetailsMaterialAccessor.Insert(proMaterial); } foreach (Model.PronoteProceduresDetail detailProcedures in pronoteHeader.DetailProcedures) { if (detailProcedures.PronoteProceduresDetailId == null) { continue; } detailProcedures.PronoteHeader = pronoteHeader; detailProcedures.PronoteHeaderID = pronoteHeader.PronoteHeaderID; if (PronoteProceduresDetailAccessor.ExistsPrimary(detailProcedures.PronoteProceduresDetailId)) { PronoteProceduresDetailAccessor.Update(detailProcedures); } else { PronoteProceduresDetailAccessor.Insert(detailProcedures); } } if (pronoteHeader.ProceduresMachineDetail != null) { foreach (Model.ProceduresMachine item in pronoteHeader.ProceduresMachineDetail) { if (ProceduresMachineAccessor.ExistsPrimary(item.ProceduresMachineId)) { ProceduresMachineAccessor.Update(item); } else { ProceduresMachineAccessor.Insert(item); } } } }
private void UpdateAndInsert(Model.ProduceMaterial produceMaterial) { try { BL.V.BeginTransaction(); //删除旧单据 Model.ProduceMaterial produceMaterialOld = this.GetDetails(produceMaterial.ProduceMaterialID); foreach (Model.ProduceMaterialdetails produceMaterialdetails in produceMaterialOld.Details) { produceMaterialdetails.Product = productManager.Get(produceMaterialdetails.ProductId); produceMaterialdetails.Product.ProduceMaterialDistributioned = (produceMaterialdetails.Product.ProduceMaterialDistributioned == null ? 0 : produceMaterialdetails.Product.ProduceMaterialDistributioned) - (produceMaterialdetails.Materialprocessum == null ? 0 : produceMaterialdetails.Materialprocessum) + (produceMaterialdetails.Materialprocesedsum == null ? 0 : produceMaterialdetails.Materialprocesedsum); productManager.update(produceMaterialdetails.Product); } this.Delete(produceMaterial.ProduceMaterialID); //新增单据 produceMaterial.InsertTime = produceMaterial.InsertTime == null ? DateTime.Now : produceMaterial.InsertTime; produceMaterial.UpdateTime = DateTime.Now; TiGuiExists(produceMaterial); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, produceMaterial.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, produceMaterial.InsertTime.Value.Year, produceMaterial.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, produceMaterial.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); accessor.Insert(produceMaterial); foreach (Model.ProduceMaterialdetails produceMaterialdetails in produceMaterial.Details) { if (produceMaterialdetails.Product == null || string.IsNullOrEmpty(produceMaterialdetails.Product.ProductId)) { throw new Exception("貨品不為空"); } produceMaterialdetails.ProduceMaterialID = produceMaterial.ProduceMaterialID; Model.Product product = productManager.Get(produceMaterialdetails.ProductId); //已分配 produceMaterialdetails.Distributioned = (product.OtherMaterialDistributioned == null ? 0 : product.OtherMaterialDistributioned) + (product.ProduceMaterialDistributioned == null ? 0 : product.ProduceMaterialDistributioned) + Convert.ToDouble(produceMaterialdetails.Materialprocessum); // produceMaterialdetails.Materialprocesedsum = produceMaterialdetails.Materialprocessum + produceMaterialdetails.Materialprocessum; ProduceMaterialdetailsAccessor.Insert(produceMaterialdetails); product.ProduceMaterialDistributioned = (product.ProduceMaterialDistributioned == null ? 0 : product.ProduceMaterialDistributioned) + (produceMaterialdetails.Materialprocessum == null ? 0 : produceMaterialdetails.Materialprocessum); productManager.update(product); ////物料需求领料描述 //Model.MRSdetails mrsdetail; //if (produceMaterialdetails.MRSdetailsId != null) //{ // mrsdetail = new BL.MRSdetailsManager().Get(produceMaterialdetails.MRSdetailsId); // if (mrsdetail != null) // { // mrsdetail.MaterialDesc = "已生成領料單"; // new BL.MRSdetailsManager().Update(mrsdetail); // } //} //if (product.ProduceMaterialDistributioned + product.OtherMaterialDistributioned > product.StocksQuantity) //{ // throw new Helper.MessageValueException(product.ProductName + " ," + "領料數量大於未分配數量"); //} } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public void Insert(Model.StockCheck stockCheck) { // // todo:add other logic here // stockCheck.InsertTime = DateTime.Now; stockCheck.UpdateTime = DateTime.Now; Validate(stockCheck); try { BL.V.BeginTransaction(); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, stockCheck.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, stockCheck.InsertTime.Value.Year, stockCheck.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, stockCheck.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = invoiceKind; SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); //设置盘点录入表为已校正 Model.StockEditor stockEditor = stockEditorAccessor.Get(stockCheck.StockEditorId); stockEditor.IsStockCheck = true; stockEditorAccessor.Update(stockEditor); accessor.Insert(stockCheck); //Dictionary<string, Model.StockCheckDetail> dic = new Dictionary<string, Book.Model.StockCheckDetail>(); foreach (Model.StockCheckDetail details in stockCheck.Details) { if (details.Product == null || string.IsNullOrEmpty(details.Product.ProductId)) { continue; } //if (!dic.ContainsKey(details.Product.ProductId)) // dic.Add(details.Product.ProductId, details); stockCheckDetailAccessor.Insert(details); Model.Stock stock = stockManager.GetStockByProductIdAndDepotPositionId(details.ProductId, details.DepotPositionId); if (stock == null) { stock = new Book.Model.Stock(); stock.StockCheckDate = stockCheck.StockCheckDate; stock.StockId = Guid.NewGuid().ToString(); stock.DepotPositionId = details.DepotPositionId; stock.DepotId = stockCheck.DepotId; stock.ProductId = details.ProductId; stock.StockQuantityOld = 0; stock.StockQuantity1 = details.StockCheckQuantity; stock.IsNotUpdate = true; stockManager.Insert(stock); } else { stock.StockCheckDate = stockCheck.StockCheckDate; stock.DepotPositionId = details.DepotPositionId; stock.StockQuantityOld = stock.StockQuantity1 == null ? 0 : stock.StockQuantity1; stock.StockQuantity1 = details.StockCheckQuantity; stock.IsNotUpdate = true; stockManager.Update(stock); } // product.StocksQuantity = stockManager.GetTheCount1OfProductByProductId(product, dic[productId].Depot); //details.Product.StocksQuantity = details.StockCheckQuantity; //修改產品 //productmanager.UpdateProduct_Stock(details.Product); details.Product.StocksQuantity = stockManager.GetTheCountByProduct(details.Product); details.Product.LastStockTakeTime = DateTime.Now; productmanager.update(details.Product); } //foreach (string productId in dic.Keys) //{ // Model.Product product = productmanager.Get(productId); // if (product.ProductImage == null) // product.ProductImage = new byte[] { }; // if (product.ProductImage1 == null) // product.ProductImage1 = new byte[] { }; // if (product.ProductImage2 == null) // product.ProductImage2 = new byte[] { }; // if (product.ProductImage3 == null) // product.ProductImage3 = new byte[] { }; // // product.StocksQuantity = stockManager.GetTheCount1OfProductByProductId(product, dic[productId].Depot); // product.StocksQuantity = dic[productId].StockCheckQuantity; // //修改產品 // productmanager.update(product); //} BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a ProduceOtherCompact. /// </summary> public void Insert(Model.ProduceOtherCompact produceOtherCompact) { // // todo:add other logic here // produceOtherCompact.InsertTime = DateTime.Now; produceOtherCompact.UpdateTime = DateTime.Now; Validate(produceOtherCompact); TiGuiExists(produceOtherCompact); try { if (this.ExistsPrimary(produceOtherCompact.ProduceOtherCompactId)) { produceOtherCompact.ProduceOtherCompactId = this.GetId(); } BL.V.BeginTransaction(); string invoiceKind = this.GetInvoiceKind().ToLower(); //string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, produceOtherCompact.InsertTime.Value.Year); //string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, produceOtherCompact.InsertTime.Value.Year, produceOtherCompact.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, produceOtherCompact.InsertTime.Value.ToString("yyyy-MM-dd")); //string sequencekey = string.Format(invoiceKind); //SequenceManager.Increment(sequencekey_y); //SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); //SequenceManager.Increment(sequencekey); produceOtherCompact.InvoiceStatus = 1; accessor.Insert(produceOtherCompact); foreach (Model.ProduceOtherCompactDetail produceOtherCompactDetail in produceOtherCompact.Details) { if (produceOtherCompactDetail.Product == null || string.IsNullOrEmpty(produceOtherCompactDetail.ProductId)) { throw new Exception("貨品不為空"); } if (produceOtherCompactDetail.OtherCompactCount < 0) { continue; } produceOtherCompactDetail.ProduceOtherCompactId = produceOtherCompact.ProduceOtherCompactId; Model.MPSdetails mpsDal = new BL.MPSdetailsManager().Get(produceOtherCompactDetail.MPSDetailId); //double Sum = new PronotedetailsManager().GetByMPSdetail(produceOtherCompactDetail.MPSDetailId); if (mpsDal != null) { mpsDal.MPSHasSingleSum += produceOtherCompactDetail.OtherCompactCount; if (mpsDal.MPSHasSingleSum == mpsDal.MPSdetailssum) { mpsDal.MPSEndState = true; } new BL.MPSdetailsManager().Update(mpsDal); } ProduceOtherCompactDetailAccessor.Insert(produceOtherCompactDetail); } foreach (Model.ProduceOtherCompactMaterial detailMaterial in produceOtherCompact.DetailMaterial) { if (string.IsNullOrEmpty(detailMaterial.ProductId)) { continue; } detailMaterial.ProduceOtherCompactId = produceOtherCompact.ProduceOtherCompactId; //Model.MPSdetails mpsDal = new BL.MPSdetailsManager().Get(produceOtherCompactDetail.MPSDetailId); ////double Sum = new PronotedetailsManager().GetByMPSdetail(produceOtherCompactDetail.MPSDetailId); //if (mpsDal != null) //{ // mpsDal.MPSHasSingleSum += produceOtherCompactDetail.OtherCompactCount; // if (mpsDal.MPSHasSingleSum == mpsDal.MPSdetailssum) // { // mpsDal.MPSEndState = true; // } // new BL.MPSdetailsManager().Update(mpsDal); //} ProduceOtherCompactMaterialAccessor.Insert(detailMaterial); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
protected string GetEntityId(DateTime dt) { string settingId = this.GetSettingId(); string invoiceKind = this.GetInvoiceKind().ToLower(); datetime = dt; if (string.IsNullOrEmpty(invoiceKind) || string.IsNullOrEmpty(settingId)) { return(string.Empty); } string rule = Settings.Get(settingId); if (string.IsNullOrEmpty(rule)) { return(string.Empty); } string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, datetime.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, datetime.Year, datetime.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, datetime.ToString("yyyy-MM-dd")); string sequencekey = invoiceKind; if (rule.IndexOf("{D2}") >= 0) { sequencekey = sequencekey_d; } else if (rule.IndexOf("{M2}") >= 0) { sequencekey = sequencekey_m; } else if (rule.IndexOf("{Y2}") >= 0 || rule.IndexOf("{Y4}") >= 0) { sequencekey = sequencekey_y; } else { sequencekey = invoiceKind; } int sequenceval = SequenceManager.GetCurrentVal(sequencekey); int a = sequenceval; sequenceval++; string d2 = string.Format("{0:d2}", datetime.Day); string m2 = string.Format("{0:d2}", datetime.Month); string y2 = string.Format("{0:d2}", datetime.Year); string y4 = string.Format("{0:d4}", datetime.Year); string n4 = string.Format("{0:d4}", (int)sequenceval); string n1 = string.Format("{0:d1}", sequenceval); string n2 = string.Format("{0:d2}", sequenceval); string n3 = string.Format("{0:d3}", sequenceval); string n5 = string.Format("{0:d5}", sequenceval); string n6 = string.Format("{0:d6}", sequenceval); string n7 = string.Format("{0:d7}", sequenceval); string n8 = string.Format("{0:d8}", sequenceval); string n9 = string.Format("{0:d9}", sequenceval); string n10 = string.Format("{0:d10}", sequenceval); return(rule.Replace("{D2}", d2).Replace("{M2}", m2).Replace("{Y2}", y2).Replace("{Y4}", y4).Replace("{N}", n4).Replace("{N1}", n1).Replace("{N2}", n2).Replace("{N3}", n3).Replace("{N4}", n4).Replace("{N5}", n5).Replace("{N6}", n6).Replace("{N7}", n7).Replace("{N8}", n8).Replace("{N9}", n9).Replace("{N10}", n10)); }
/// <summary> /// Insert a MPSheader. /// </summary> public void Insert(Model.MPSheader mPSheader) { // // todo:add other logic here // Validate(mPSheader); try { BL.V.BeginTransaction(); mPSheader.InsertTime = DateTime.Now; TiGuiExists(mPSheader); mPSheader.UpdateTime = DateTime.Now; string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, mPSheader.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, mPSheader.InsertTime.Value.Year, mPSheader.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, mPSheader.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); if (mPSheader.Details != null && mPSheader.Details.Count > 0) { mPSheader.InvoiceXOId = mPSheader.Details[0].InvoiceXOId; } accessor.Insert(mPSheader); foreach (Model.MPSdetails mPSdetails in mPSheader.Details) { if (mPSdetails.Product == null || string.IsNullOrEmpty(mPSdetails.Product.ProductId)) { continue; } mPSdetails.MPSheaderId = mPSheader.MPSheaderId; mPSdetails.MPSEndState = false; invoiceXODetail = invoiceManager.Get(mPSdetails.InvoiceXODetailId); double ss = MPSdetailsAccessor.GetByInvoiceXODetailId(mPSdetails.InvoiceXODetailId); MPSdetailsAccessor.Insert(mPSdetails); if (invoiceXODetail != null) { if (invoiceXODetail.InvoiceMPSQuantity == null) { invoiceXODetail.InvoiceMPSQuantity = 0; } invoiceXODetail.InvoiceMPSQuantity += mPSdetails.MPSdetailssum; if (invoiceXODetail.InvoiceMPSQuantity >= invoiceXODetail.InvoiceXODetailQuantity) { invoiceXODetail.DetailMPSState = 2; } else { if (invoiceXODetail.InvoiceMPSQuantity > 0) { invoiceXODetail.DetailMPSState = 1; } else { invoiceXODetail.DetailMPSState = 0; } } //invoiceXODetail.InvoiceMPSQuantity = Convert.ToDouble(MPSdetailsAccessor.GetByInvoiceXODetailId(mPSdetails.InvoiceXODetailId)); invoiceManager.Update(invoiceXODetail); UpdateInvoiceXOFlag(invoiceXODetail.Invoice); } // Model.Product product = productManager.Get(mPSdetails.ProductId); //if (product.MpsStockQuantity == null || product.MpsStockQuantity == 0) //{ // product.MpsStockQuantity = mPSdetails.Product.StocksQuantity; // ProductAccessor.Update(product); this.UpdateSql("update product set MpsStockQuantity=" + mPSdetails.MPSdetailssum + " where productid='" + mPSdetails.ProductId + "'"); // } } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a Supplier. /// </summary> public void Insert(Model.Supplier supplier) { // // todo:add other logic here // Validate(supplier); if (this.Exists(supplier.Id)) { throw new Helper.InvalidValueException(Model.Supplier.PROPERTY_ID); } try { V.BeginTransaction(); //设置KEY值 if (supplier.SupplierCategory != null) { string sequencekey = supplier.SupplierCategory.Id; SequenceManager.Increment("suppliercategory" + sequencekey); } if (supplier.AreaCategory != null) { supplier.AreaCategoryId = supplier.AreaCategory.AreaCategoryId; } if (supplier.TradeCategory != null) { supplier.TradeCategoryId = supplier.TradeCategory.TradeCategoryId; } if (supplier.SupplierCategory != null) { supplier.SupplierCategoryId = supplier.SupplierCategory.SupplierCategoryId; } if (supplier.PayMethod != null) { supplier.PayMethodId = supplier.PayMethod.PayMethodId; } supplier.SupplierId = Guid.NewGuid().ToString(); supplier.InsertTime = DateTime.Now; supplier.EmployeeChangeId = V.ActiveOperator.OperatorName; accessor.Insert(supplier); foreach (Model.SupplierContact contact in supplier.Contacts) { contact.Supplier = supplier; contact.SupplierId = supplier.SupplierId; if (string.IsNullOrEmpty(contact.SupplierContactId)) { contact.SupplierContactId = Guid.NewGuid().ToString(); } supplierContactAccessor.Insert(contact); } V.CommitTransaction(); } catch (Exception ex) { V.RollbackTransaction(); throw ex; } }
public void Insert(Model.ProduceOtherMaterial produceOtherMaterial) { Validate(produceOtherMaterial); try { produceOtherMaterial.InsertTime = produceOtherMaterial.InsertTime == null ? DateTime.Now : produceOtherMaterial.InsertTime; produceOtherMaterial.UpdateTime = DateTime.Now; BL.V.BeginTransaction(); this.TiGuiExists(produceOtherMaterial); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, produceOtherMaterial.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, produceOtherMaterial.InsertTime.Value.Year, produceOtherMaterial.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, produceOtherMaterial.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); produceOtherMaterial.InvoiceStatus = 1; accessor.Insert(produceOtherMaterial); foreach (Model.ProduceOtherMaterialDetail produceOtherMaterialDetail in produceOtherMaterial.Details) { if (produceOtherMaterialDetail.Product == null || string.IsNullOrEmpty(produceOtherMaterialDetail.Product.ProductId)) { throw new Exception("貨品不為空"); } //if (produceOtherMaterialDetail.DepotPositionId == null) // throw new Helper.MessageValueException("貨位不能為空!"); produceOtherMaterialDetail.ProduceOtherMaterialId = produceOtherMaterial.ProduceOtherMaterialId; Model.Product product = productManager.Get(produceOtherMaterialDetail.ProductId); //已分配 produceOtherMaterialDetail.Distributioned = (product.OtherMaterialDistributioned == null ? 0 : product.OtherMaterialDistributioned) + (produceOtherMaterialDetail.OtherMaterialQuantity == null ? 0 : produceOtherMaterialDetail.OtherMaterialQuantity); ProduceOtherMaterialDetailAccessor.Insert(produceOtherMaterialDetail); product.OtherMaterialDistributioned = (product.OtherMaterialDistributioned == null ? 0 : product.OtherMaterialDistributioned) + (produceOtherMaterialDetail.OtherMaterialQuantity == null ? 0 : produceOtherMaterialDetail.OtherMaterialQuantity); productManager.update(product); ////Model.Stock stock = stockAccessor.GetStockByProductIdAndDepotPositionId(produceOtherMaterialDetail.ProductId, produceOtherMaterialDetail.DepotPositionId); // stockAccessor.Increment(new BL.DepotPositionManager().Get(produceOtherMaterialDetail.DepotPositionId), produceOtherMaterialDetail.Product, -produceOtherMaterialDetail.OtherMaterialQuantity); //Model.ProduceOtherCompactMaterial produceOtherCompactMaterial = produceOtherCompactMaterialAccessor.Get(produceOtherMaterialDetail.ProduceOtherCompactMaterialId); //if (produceOtherCompactMaterial != null) //{ // if (produceOtherCompactMaterial.AlreadyOutQuantity == null) // produceOtherCompactMaterial.AlreadyOutQuantity = 0; // produceOtherCompactMaterial.AlreadyOutQuantity += produceOtherMaterialDetail.OtherMaterialQuantity; // if (produceOtherCompactMaterial.AlreadyOutQuantity >= produceOtherCompactMaterial.ProduceQuantity) // { // produceOtherCompactMaterial.DetailsFlag = 2; // } // else // { // if (produceOtherCompactMaterial.AlreadyOutQuantity > 0) // { // produceOtherCompactMaterial.DetailsFlag = 1; // } // else // { // produceOtherCompactMaterial.DetailsFlag = 0; // } // } // produceOtherCompactMaterialAccessor.Update(produceOtherCompactMaterial); // UpdateProduceOtherCompactFlag(produceOtherCompactMaterial.ProduceOtherCompact); //} } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a Product. /// </summary> public void Insert(Model.Product product) { this.Validate(product); //if (this.Exists(product.Id)) //{ //throw new Helper.InvalidValueException(Model.Product.PRO_Id); TiGuiExists(product); // } if (this.ExistsNameInsert(product.ProductName)) { throw new Helper.InvalidValueException(Model.Product.PRO_ProductName); } //设置KEY值 string sequencekey = product.ProductCategory.Id; SequenceManager.Increment(sequencekey); StringBuilder strBU = new StringBuilder(); string PrId = Guid.NewGuid().ToString(); product.ProductId = PrId; if (product.BasedUnitGroup != null) { product.BasedUnitGroupId = product.BasedUnitGroup.UnitGroupId; } if (product.BuyEmployee != null) { product.BuyEmployeeId = product.BuyEmployee.EmployeeId; } if (product.BuyUnit != null) { product.BuyUnitId = product.BuyUnit.ProductUnitId; } if (product.CustomInspectionRule != null) { product.CustomInspectionRuleId = product.CustomInspectionRule.CustomInspectionRuleId; } if (product.Depot != null) { product.DepotId = product.Depot.DepotId; } if (product.DepotPosition != null) { product.DepotPositionId = product.DepotPosition.DepotPositionId; } if (product.DepotUnit != null) { product.DepotUnitId = product.DepotUnit.ProductUnitId; } //if (product.InsteadOfProductId != null) product.InsteadOfProductId = product.InsteadOfProduct.ProductId; if (product.MainUnit != null) { product.MainUnitId = product.MainUnit.ProductUnitId; } // if (product.PackageType != null) product.PackageTypeId = product.PackageType.PackageTypeId; if (product.ProduceUnit != null) { product.ProduceUnitId = product.ProduceUnit.ProductUnitId; } if (product.ProductCategory != null) { product.ProductCategoryId = product.ProductCategory.ProductCategoryId; } if (product.QualityTestPlan != null) { product.QualityTestPlanId = product.QualityTestPlan.QualityTestPlanId; } if (product.QualityTestUnit != null) { product.QualityTestUnitId = product.QualityTestUnit.ProductUnitId; } if (product.SellUnit != null) { product.SellUnitId = product.SellUnit.ProductUnitId; } // if (product.Supplier != null) product.SupplierId = product.Supplier.SupplierId; product.SupplierId = product.Supplier == null ? null : product.Supplier.SupplierId; if (product.VolumeUnit != null) { product.VolumeUnitId = product.VolumeUnit.ProductUnitId; } if (product.VolumeUnitGroup != null) { product.VolumeUnitGroupId = product.VolumeUnitGroup.UnitGroupId; } if (product.WeightUnit != null) { product.WeightUnitId = product.WeightUnit.ProductUnitId; } if (product.WeightUnitGroup != null) { product.WeightUnitGroupId = product.WeightUnitGroup.UnitGroupId; } //if (product.ProductImage == null) // product.ProductImage = pic; //if (product.ProductImage1 == null) // product.ProductImage1 = pic; //if (product.ProductImage2 == null) // product.ProductImage2 = pic; //if (product.ProductImage3 == null) // product.ProductImage3 = pic; product.ProductCategoryId = product.ProductCategory.ProductCategoryId; product.InsertTime = DateTime.Now; //product.UpdateTime = DateTime.Now; accessor.Insert(product); //ProductProcessAccessor.Delete(product); foreach (Model.ProductMouldDetail Pro in product.ProductMouldDetail) { if (string.IsNullOrEmpty(Pro.ProductMouldDetailId)) { continue; } Pro.ProductId = product.ProductId; ProductMouldDetailAccessor.Insert(Pro); } //自动生成对应的BOM单 //string bomsql = " ProductId= '" + product.ProductId + "'"; //if (!bomParentPartInfoAccessor.Exists_Field(bomsql)) //{ //Model.BomParentPartInfo bom = new Book.Model.BomParentPartInfo(); //bom.BomId = Guid.NewGuid().ToString(); //bom.Product = product; //bom.ProductId = product.ProductId; //bom.Id = new BL.BomParentPartInfoManager().GetId(); //bom.LossRate = 0; //bom.EffectiveDate = DateTime.Now; //bom.DefaultQuantity = 1; //bom.Status = 0; //bom.IsEdit = "*"; //new BL.BomParentPartInfoManager().Insert(bom); //} //foreach (Model.ProductProcess Pro in product.ProductProcess) //{ // if (string.IsNullOrEmpty(Pro.ProcessCategoryId)) continue; // //strBU.Append(Pro.ProcessCategory.ProcessCategoryName); // Pro.ProductProcessId = Guid.NewGuid().ToString(); // Pro.ProductId = product.ProductId; // Pro.ProcessId = Pro.Process == null ? null : Pro.Process.ProcessId; // Pro.ProcessCategoryId = Pro.ProcessCategory == null ? null : Pro.ProcessCategory.ProcessCategoryId; // ProductProcessAccessor.Insert(Pro); //} //加工后名称添加 ////if (product.ProductProcess!=null) ////{ //// if (product.ProductProcess.Count > 0) //// { //// product.ProductId = Guid.NewGuid().ToString(); //// ////product.ProductName = product.ProProcessName;0827 //// ProductProcessAccessor.Delete(product); //// product.ProceebeforeProductId = PrId; //// product.IsProcee = true; //// accessor.Insert(product); //// foreach (Model.ProductProcess Pro in product.ProductProcess) //// { //// if (Pro.ProcessCategory == null) continue; //// Pro.ProductProcessId = Guid.NewGuid().ToString(); //// Pro.ProductId = product.ProductId; //// Pro.ProcessId = Pro.Process == null ? null : Pro.Process.ProcessId; //// Pro.ProcessCategoryId = Pro.ProcessCategory == null ? null : Pro.ProcessCategory.ProcessCategoryId; //// ProductProcessAccessor.Insert(Pro); //// } //// } ////} //} //自动产生对应的厂商商品 if (!string.IsNullOrEmpty(product.SupplierId)) { Model.SupplierProduct supplierProduct = new Book.Model.SupplierProduct(); supplierProduct.SupplierProductId = Guid.NewGuid().ToString(); supplierProduct.SupplierId = product.SupplierId; supplierProduct.ProductId = product.ProductId; supplierProduct.InsertTime = DateTime.Now; supplierProduct.UpdateTime = DateTime.Now; supplierProduct.SupplierProductPriceRange = "1/999999999999/0/0"; supplierProductAccessor.Insert(supplierProduct); } }
public void InsertAtSummon(Model.InvoiceXS invoice, Dictionary <string, string> dic) { Model.AtSummon atSummon = new Book.Model.AtSummon(); atSummon.SummonId = Guid.NewGuid().ToString(); atSummon.SummonDate = DateTime.Now; atSummon.SummonCategory = "轉帳傳票"; atSummon.InsertTime = DateTime.Now; atSummon.UpdateTime = DateTime.Now; //atSummon.Id = this.atSummonManager.GetId(); atSummon.Id = this.atSummonManager.GetConsecutiveId(DateTime.Now); atSummon.InvoiceXSId = invoice.InvoiceId; atSummon.Details = new List <Model.AtSummonDetail>(); Model.AtSummonDetail detail1 = new Model.AtSummonDetail(); detail1.SummonDetailId = Guid.NewGuid().ToString(); detail1.SummonCatetory = atSummon.SummonCategory; detail1.Lending = "借"; detail1.AMoney = invoice.InvoiceTotal; detail1.SubjectId = dic[string.Format("應收帳款-{0}", invoice.Customer.CustomerShortName)]; detail1.InsertTime = DateTime.Now; detail1.UpdateTime = DateTime.Now; atSummon.Details.Add(detail1); Model.AtSummonDetail detail2 = new Model.AtSummonDetail(); detail2.SummonDetailId = Guid.NewGuid().ToString(); detail2.SummonCatetory = atSummon.SummonCategory; detail2.Lending = "貸"; detail2.AMoney = invoice.InvoiceHeji; detail2.SubjectId = dic["銷貨收入"]; detail2.InsertTime = DateTime.Now; detail2.UpdateTime = DateTime.Now; atSummon.Details.Add(detail2); if (invoice.InvoiceTax > 0) { Model.AtSummonDetail detail3 = new Model.AtSummonDetail(); detail3.SummonDetailId = Guid.NewGuid().ToString(); detail3.SummonCatetory = atSummon.SummonCategory; detail3.Lending = "貸"; detail3.AMoney = invoice.InvoiceTax; detail3.SubjectId = dic["銷項稅額"]; detail3.InsertTime = DateTime.Now; detail3.UpdateTime = DateTime.Now; atSummon.Details.Add(detail3); } foreach (var item in atSummon.Details) { if (item.Lending == "借") { item.Id = "A" + atSummon.Details.IndexOf(item); } else { item.Id = "B" + atSummon.Details.IndexOf(item); } } atSummonManager.TiGuiExists(atSummon); //插入 string invoiceKind = "ats"; string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, atSummon.SummonDate.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, atSummon.SummonDate.Value.Year, atSummon.SummonDate.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, atSummon.SummonDate.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); atSummon.TotalDebits = atSummon.Details.Where(d => d.Lending == "借").Sum(d => d.AMoney); atSummon.CreditTotal = atSummon.Details.Where(d => d.Lending == "貸").Sum(d => d.AMoney); atSummonAccessor.Insert(atSummon); foreach (Model.AtSummonDetail atSummonDetail in atSummon.Details) { atSummonDetail.SummonId = atSummon.SummonId; atSummonDetailManager.Insert(atSummonDetail); } }
public void Insert(Model.MRSHeader mRSHeader) { // // todo:add other logic here // Validate(mRSHeader); if (this.Exists(mRSHeader.Id)) { throw new Helper.InvalidValueException(Model.MRSHeader.PRO_Id); } try { mRSHeader.InsertTime = DateTime.Now; BL.V.BeginTransaction(); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, mRSHeader.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, mRSHeader.InsertTime.Value.Year, mRSHeader.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, mRSHeader.InsertTime.Value.ToString("yyyy-MM-dd")); string sequencekey = string.Format(invoiceKind); SequenceManager.Increment(sequencekey_y); SequenceManager.Increment(sequencekey_m); SequenceManager.Increment(sequencekey_d); SequenceManager.Increment(sequencekey); if (mRSHeader.Employee0 != null) { mRSHeader.Employee0Id = mRSHeader.Employee0.EmployeeId; } if (mRSHeader.Employee1 != null) { mRSHeader.Employee1Id = mRSHeader.Employee1.EmployeeId; } mRSHeader.InvoiceStatus = 1; accessor.Insert(mRSHeader); if (mRSHeader.Details != null) { foreach (Model.MRSdetails mRSdetails in mRSHeader.Details) { if (string.IsNullOrEmpty(mRSdetails.ProductId)) { continue; } mRSdetails.MRSHeaderId = mRSHeader.MRSHeaderId; MRSdetailsAccessor.Insert(mRSdetails); //Model.Product product =ProductAccessor.Get(mRSdetails.ProductId); //if (product.MRSStockQuantity != null ) //{ // product.MRSStockQuantity += mRSdetails.Product.StocksQuantity; // if (product.ProductImage == null) // product.ProductImage = pic; // if (product.ProductImage1 == null) // product.ProductImage1 = pic; // if (product.ProductImage2 == null) // product.ProductImage2 = pic; // if (product.ProductImage3 == null) // product.ProductImage3 = pic; // ProductAccessor.Update(product); //} } } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// 获取连续Id,比如说20200909001,20200909002,删除001后,再新增还是001 /// </summary> /// <returns></returns> public string GetConsecutiveId(DateTime dt) { string settingId = this.GetSettingId(); string invoiceKind = this.GetInvoiceKind().ToLower(); DateTime datetime = dt; if (string.IsNullOrEmpty(invoiceKind) || string.IsNullOrEmpty(settingId)) { return(string.Empty); } string rule = Settings.Get(settingId); if (string.IsNullOrEmpty(rule)) { return(string.Empty); } string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, datetime.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, datetime.Year, datetime.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, datetime.ToString("yyyy-MM-dd")); string sequencekey = invoiceKind; if (rule.IndexOf("{D2}") >= 0) { sequencekey = sequencekey_d; } else if (rule.IndexOf("{M2}") >= 0) { sequencekey = sequencekey_m; } else if (rule.IndexOf("{Y2}") >= 0 || rule.IndexOf("{Y4}") >= 0) { sequencekey = sequencekey_y; } else { sequencekey = invoiceKind; } string d2 = string.Format("{0:d2}", datetime.Day); string m2 = string.Format("{0:d2}", datetime.Month); string y2 = string.Format("{0:d2}", datetime.Year); string y4 = string.Format("{0:d4}", datetime.Year); Func <int, string> getId = (sequenceval) => { string n1 = string.Format("{0:d1}", sequenceval); string n2 = string.Format("{0:d2}", sequenceval); string n3 = string.Format("{0:d3}", sequenceval); string n4 = string.Format("{0:d4}", sequenceval); string n5 = string.Format("{0:d5}", sequenceval); string n6 = string.Format("{0:d6}", sequenceval); string n7 = string.Format("{0:d7}", sequenceval); string n8 = string.Format("{0:d8}", sequenceval); string n9 = string.Format("{0:d9}", sequenceval); string n10 = string.Format("{0:d10}", sequenceval); return(rule.Replace("{D2}", d2).Replace("{M2}", m2).Replace("{Y2}", y2).Replace("{Y4}", y4).Replace("{N}", n4).Replace("{N1}", n1).Replace("{N2}", n2).Replace("{N3}", n3).Replace("{N4}", n4).Replace("{N5}", n5).Replace("{N6}", n6).Replace("{N7}", n7).Replace("{N8}", n8).Replace("{N9}", n9).Replace("{N10}", n10)); }; //int sequenceval = 1; int currentVal = SequenceManager.GetCurrentVal(sequencekey); //sequenceval++; string id = ""; for (int i = 1; i <= currentVal; i++) { id = getId(i); if (!IsExistsId(id)) { return(id); } } id = getId(++currentVal); return(id); }