/// <summary> /// Insert a ProduceOtherCompactDetail. /// </summary> public void Insert(Model.ProduceOtherCompactDetail produceOtherCompactDetail) { // // todo:add other logic here // accessor.Insert(produceOtherCompactDetail); }
/// <summary> /// Update a ProduceOtherCompactDetail. /// </summary> public void Update(Model.ProduceOtherCompactDetail produceOtherCompactDetail) { // // todo: add other logic here. // accessor.Update(produceOtherCompactDetail); }
private void simpleButton2_Click(object sender, EventArgs e) { if (this.bindingSourceDetails.Current != null) { this._produceOtherCompact.Details.Remove(this.bindingSourceDetails.Current as Book.Model.ProduceOtherCompactDetail); if (this._produceOtherCompact.Details.Count == 0) { Model.ProduceOtherCompactDetail detail = new Model.ProduceOtherCompactDetail(); detail.OtherCompactDetailId = Guid.NewGuid().ToString(); detail.OtherCompactCount = 0; detail.OtherCompactPrice = 0; detail.InDepotCount = 0; detail.OtherCompactMoney = 0; detail.ProductSpecification = ""; detail.Inumber = this._produceOtherCompact.Details.Count + 1; detail.Product = new Book.Model.Product(); this._produceOtherCompact.Details.Add(detail); this.bindingSourceDetails.Position = this.bindingSourceDetails.IndexOf(detail); } this.SettingForINumber(); this.gridControl1.RefreshDataSource(); } }
/// <summary> /// Insert a ProduceOtherReturnMaterial. /// </summary> public void Insert(Model.ProduceOtherReturnMaterial produceOtherReturnMaterial) { // // todo:add other logic here // // Valid(produceOtherReturnMaterial); try { BL.V.BeginTransaction(); produceOtherReturnMaterial.InsertTime = DateTime.Now; produceOtherReturnMaterial.UpdateTime = DateTime.Now; TiGuiExists(produceOtherReturnMaterial); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, produceOtherReturnMaterial.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, produceOtherReturnMaterial.InsertTime.Value.Year, produceOtherReturnMaterial.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, produceOtherReturnMaterial.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(produceOtherReturnMaterial); foreach (Model.ProduceOtherReturnDetail item in produceOtherReturnMaterial.Details) { item.ProduceOtherReturnMaterialId = produceOtherReturnMaterial.ProduceOtherReturnMaterialId; accessorDetail.Insert(item); Model.ProduceOtherCompactDetail CompactDetail = produceOtherCompactDetailAccessor.Get(item.ProduceOtherCompactDetailId); if (CompactDetail != null) { if (CompactDetail.CancelQuantity == null) { CompactDetail.CancelQuantity = 0; } CompactDetail.CancelQuantity += item.Quantity; produceOtherCompactDetailAccessor.Update(CompactDetail); } //stockAccess.Increment(depotpositionAccess.Get(item.DepotPositionId), item.Product, item.Quantity); //item.Product.StocksQuantity += stockAccess.GetTheCountByProduct(item.Product); //item.Product.ProductImage = new byte[0]; //item.Product.ProductImage1 = new byte[0]; //item.Product.ProductImage2 = new byte[0]; //item.Product.ProductImage3 = new byte[0]; //productAccess.Update(item.Product); } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
private void CancelAffect(Model.ProduceOtherReturnMaterial model) { foreach (Model.ProduceOtherReturnDetail item in accessorDetail.Select(model)) { Model.ProduceOtherCompactDetail CompactDetail = produceOtherCompactDetailAccessor.Get(item.ProduceOtherCompactDetailId); if (CompactDetail != null) { CompactDetail.CancelQuantity = CompactDetail.CancelQuantity == null ? 0 : CompactDetail.CancelQuantity - item.Quantity; produceOtherCompactDetailAccessor.Update(CompactDetail); } } }
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.ListSourceRowIndex < 0) { return; } IList <Model.ProduceOtherCompactDetail> details = this.bindingSourceDetail.DataSource as IList <Model.ProduceOtherCompactDetail>; Model.ProduceOtherCompactDetail detailss = details[e.ListSourceRowIndex]; Model.ProduceOtherCompact detail = details[e.ListSourceRowIndex].ProduceOtherCompact; switch (e.Column.Name) { //case "gridColumn2": // if (detail == null) return; // e.DisplayText = detail.ProduceOtherCompactDate.Value.ToString("yyyy-MM-dd"); // break; case "gridColumn3": if (detail == null) { return; } e.DisplayText = detail.Supplier == null ? "" : detail.Supplier.SupplierShortName; break; case "gridColumnguige": if (detailss == null) { return; } e.DisplayText = detailss == null ? "" : detailss.ProductSpecification; break; case "gridColumnProductId": if (detailss == null) { return; } e.DisplayText = detailss.Product == null ? "" : detailss.Product.Id; break; case "gridColumnstock": if (detailss == null || detailss.Product.StocksQuantity == null) { return; } e.DisplayText = detailss.Product.StocksQuantity.ToString(); break; } }
public void Delete(Model.PCOtherCheck model) { try { BL.V.BeginTransaction(); foreach (var item in model.Detail) { //采购单已做过进料检验的数量 if (item.PCOtherCheckDetailFromPC == "1") { Model.InvoiceCODetail codetail = this.codetailManager.Get(item.FromInvoiceDetailID); if (codetail != null) { codetail.HasCheckQuantity = Convert.ToDecimal(codetail.HasCheckQuantity) - Convert.ToDecimal(item.InQuantity); codetail.HasCheckQuantity = codetail.HasCheckQuantity < 0 ? 0 : codetail.HasCheckQuantity; this.codetailManager.Update(codetail); } } //委外合同 if (item.PCOtherCheckDetailFromPC == "0") { Model.ProduceOtherCompactDetail pocdetail = this.pocdetailManager.Get(item.FromInvoiceDetailID); if (pocdetail != null) { pocdetail.HasCheckQuantity = Convert.ToDecimal(pocdetail.HasCheckQuantity) - Convert.ToDecimal(item.InQuantity); pocdetail.HasCheckQuantity = pocdetail.HasCheckQuantity < 0 ? 0 : pocdetail.HasCheckQuantity; this.pocdetailManager.Update(pocdetail); } } } PCOtherCheckDetailAccessor.DeleteByPCOCId(model.PCOtherCheckId); this.Delete(model.PCOtherCheckId); BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column == this.ColProductId) { Model.ProduceOtherCompactDetail detail = this.gridView1.GetRow(e.RowHandle) as Model.ProduceOtherCompactDetail; if (detail != null) { Model.Product p = productManager.Get(e.Value.ToString()); detail.OtherCompactDetailId = Guid.NewGuid().ToString(); detail.OtherCompactCount = 0; detail.OtherCompactPrice = 0; detail.InDepotCount = 0; detail.OtherCompactMoney = 0; detail.Product = p; detail.ProductId = p.ProductId; detail.ProductSpecification = p.ProductSpecification; this.bindingSourceDetails.Position = this.bindingSourceDetails.IndexOf(detail); } this.gridControl1.RefreshDataSource(); } }
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column == this.ColOtherCompactPrice || e.Column == this.ColOtherCompactCount) { decimal price = decimal.Zero; decimal quantity = decimal.Zero; if (e.Column == this.ColOtherCompactPrice) { decimal.TryParse(e.Value == null ? "0" : e.Value.ToString(), out price); decimal.TryParse(this.gridView1.GetRowCellValue(e.RowHandle, this.ColOtherCompactCount) == null ? "" : this.gridView1.GetRowCellValue(e.RowHandle, this.ColOtherCompactCount).ToString(), out quantity); } if (e.Column == this.ColOtherCompactCount) { string PriceRange = string.Empty; decimal.TryParse(e.Value == null ? "0" : e.Value.ToString(), out quantity); Model.ProduceOtherCompactDetail detail = this.bindingSourceDetails.Current as Model.ProduceOtherCompactDetail; if ((this.newChooseSupplierId.EditValue as Model.Supplier) == null) { MessageBox.Show("廠商為空,不能計算商品單價!", this.Text); } else { PriceRange = (new BL.SupplierProductManager()).GetPriceRangeForSupAndProduct((this.newChooseSupplierId.EditValue as Model.Supplier).SupplierId, detail.ProductId); } if (string.IsNullOrEmpty(PriceRange)) { decimal.TryParse(this.gridView1.GetRowCellValue(e.RowHandle, this.ColOtherCompactPrice).ToString(), out price); } else { price = BL.SupplierProductManager.CountPrice(PriceRange, Convert.ToDouble(quantity)); this.gridView1.SetRowCellValue(e.RowHandle, this.ColOtherCompactPrice, price); } } this.gridView1.SetRowCellValue(e.RowHandle, this.ColOtherCompactMoney, price * quantity); } this.gridControl1.RefreshDataSource(); }
private void CancelAffect(Model.ProduceOtherInDepot produceOtherInDepot, int tag) { foreach (Model.ProduceOtherInDepotDetail item in ProduceOtherInDepotDetailAccessor.Select(produceOtherInDepot)) { if (!string.IsNullOrEmpty(item.DepotPositionId)) { stockAccessor.Increment(new BL.DepotPositionManager().Get(item.DepotPositionId), item.Product, -item.ProduceInDepotQuantity); this.productManager.UpdateProduct_Stock(item.Product); } Model.ProduceOtherCompactDetail CompactDetail = produceOtherCompactDetailAccessor.Get(item.ProduceOtherCompactDetailId); if (CompactDetail != null) { CompactDetail.InDepotCount = CompactDetail.InDepotCount == null ? 0 : CompactDetail.InDepotCount - item.ProduceQuantity; CompactDetail.ArrivalInQuantity = CompactDetail.ArrivalInQuantity == null ? 0 : CompactDetail.ArrivalInQuantity - item.ProduceQuantity; if (CompactDetail.InDepotCount >= CompactDetail.OtherCompactCount) { CompactDetail.DetailsFlag = 2; } else { if (CompactDetail.InDepotCount > 0) { CompactDetail.DetailsFlag = 1; } else { CompactDetail.DetailsFlag = 0; } } produceOtherCompactDetailAccessor.Update(CompactDetail); if (tag == 1) { UpdateProduceOtherCompactFlag(CompactDetail.ProduceOtherCompact); } } } }
private void gridViewDetail_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column.Name == "gridColumnChecked") { Model.ProduceOtherCompactDetail detail = this.gridViewDetail.GetRow(e.RowHandle) as Model.ProduceOtherCompactDetail; if ((bool)e.Value) { key.Add(detail); // MrsDetails.Add(this.mRSdetailsManager.Get(detail.MRSdetailsId)); } if (!(bool)e.Value) { for (int i = 0; i < key.Count; i++) { if (key[i].OtherCompactDetailId == detail.OtherCompactDetailId) { key.RemoveAt(i); break; } } } } }
/// <summary> /// Update a PCOtherCheck. /// </summary> public void Update(Model.PCOtherCheck pCOtherCheck) { Validate(pCOtherCheck); if (pCOtherCheck != null) { //修改头 pCOtherCheck.UpdateTime = DateTime.Now; accessor.Update(pCOtherCheck); //删除详细 IList <Model.PCOtherCheckDetail> Oldlist = PCOtherCheckDetailAccessor.Selct(pCOtherCheck); foreach (var item in Oldlist) { //采购单已做过进料检验的数量 if (item.PCOtherCheckDetailFromPC == "1") { Model.InvoiceCODetail codetail = this.codetailManager.Get(item.FromInvoiceDetailID); if (codetail != null) { codetail.HasCheckQuantity = Convert.ToDecimal(codetail.HasCheckQuantity) - Convert.ToDecimal(item.InQuantity); codetail.HasCheckQuantity = codetail.HasCheckQuantity < 0 ? 0 : codetail.HasCheckQuantity; this.codetailManager.Update(codetail); } } //委外合同 if (item.PCOtherCheckDetailFromPC == "0") { Model.ProduceOtherCompactDetail pocdetail = this.pocdetailManager.Get(item.FromInvoiceDetailID); if (pocdetail != null) { pocdetail.HasCheckQuantity = Convert.ToDecimal(pocdetail.HasCheckQuantity) - Convert.ToDecimal(item.InQuantity); pocdetail.HasCheckQuantity = pocdetail.HasCheckQuantity < 0 ? 0 : pocdetail.HasCheckQuantity; this.pocdetailManager.Update(pocdetail); } } } PCOtherCheckDetailAccessor.DeleteByPCOCId(pCOtherCheck.PCOtherCheckId); //添加详细 foreach (Model.PCOtherCheckDetail details in pCOtherCheck.Detail) { details.PCOtherCheckId = pCOtherCheck.PCOtherCheckId; PCOtherCheckDetailAccessor.Insert(details); //采购单已做过进料检验的数量 if (details.PCOtherCheckDetailFromPC == "1") { Model.InvoiceCODetail codetail = this.codetailManager.Get(details.FromInvoiceDetailID); if (codetail != null) { codetail.HasCheckQuantity = Convert.ToDecimal(codetail.HasCheckQuantity) + Convert.ToDecimal(details.InQuantity); this.codetailManager.Update(codetail); } } //委外合同 if (details.PCOtherCheckDetailFromPC == "0") { Model.ProduceOtherCompactDetail pocdetail = this.pocdetailManager.Get(details.FromInvoiceDetailID); if (pocdetail != null) { pocdetail.HasCheckQuantity = Convert.ToDecimal(pocdetail.HasCheckQuantity) + Convert.ToDecimal(details.InQuantity); this.pocdetailManager.Update(pocdetail); } } } } }
/// <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); //采购单已做过进料检验的数量 if (PcotherCheckDetail.PCOtherCheckDetailFromPC == "1") { Model.InvoiceCODetail codetail = this.codetailManager.Get(PcotherCheckDetail.FromInvoiceDetailID); if (codetail != null) { codetail.HasCheckQuantity = Convert.ToDecimal(codetail.HasCheckQuantity) + Convert.ToDecimal(PcotherCheckDetail.InQuantity); this.codetailManager.Update(codetail); } } //委外合同 if (PcotherCheckDetail.PCOtherCheckDetailFromPC == "0") { Model.ProduceOtherCompactDetail pocdetail = this.pocdetailManager.Get(PcotherCheckDetail.FromInvoiceDetailID); if (pocdetail != null) { pocdetail.HasCheckQuantity = Convert.ToDecimal(pocdetail.HasCheckQuantity) + Convert.ToDecimal(PcotherCheckDetail.InQuantity); this.pocdetailManager.Update(pocdetail); } } } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
private void simpleButton1_Click(object sender, EventArgs e) { ChooseProductForm f = new ChooseProductForm(); if (f.ShowDialog(this) == DialogResult.OK) { if (this._produceOtherCompact.Details.Count > 0 && this._produceOtherCompact.Details[0] != null && string.IsNullOrEmpty(this._produceOtherCompact.Details[0].ProductId)) { this._produceOtherCompact.Details.RemoveAt(0); } Model.ProduceOtherCompactDetail detail = null; if (ChooseProductForm.ProductList != null || ChooseProductForm.ProductList.Count > 0) { foreach (Model.Product product in ChooseProductForm.ProductList) { detail = new Book.Model.ProduceOtherCompactDetail(); detail.OtherCompactDetailId = Guid.NewGuid().ToString(); detail.Product = this.productManager.Get(product.ProductId); detail.ProductId = product.ProductId; detail.OtherCompactCount = 0; detail.OtherCompactPrice = 0; detail.InDepotCount = 0; detail.ProductUnit = product.DepotUnit == null ? null : product.DepotUnit.CnName; detail.OtherCompactMoney = 0; Model.BomParentPartInfo bompar = this.bomParentPartInfoManager.Get(product); if (bompar != null) { foreach (Model.BomComponentInfo comm in this.bomComponentInfoManager.Select(bompar)) { Model.ProduceOtherCompactMaterial mater = new Model.ProduceOtherCompactMaterial(); mater.ProduceOtherCompactMaterialId = Guid.NewGuid().ToString(); mater.Product = comm.Product; mater.ProductId = comm.ProductId; mater.ProductUnit = comm.Unit; mater.ProduceQuantity = 0; mater.ParentProduct = product; mater.ParentProductId = product.ProductId; this._produceOtherCompact.DetailMaterial.Add(mater); } } // detail.Inumber = this._produceOtherMaterial.Details.Count + 1; //detail.ProductUnit = detail.Product.MainUnit == null ? null : detail.Product.MainUnit.CnName; detail.ProductSpecification = product.ProductSpecification; detail.Inumber = this._produceOtherCompact.Details.Count + 1; this._produceOtherCompact.Details.Add(detail); } } if (ChooseProductForm.ProductList == null || ChooseProductForm.ProductList.Count == 0) { detail = new Book.Model.ProduceOtherCompactDetail(); detail.OtherCompactDetailId = Guid.NewGuid().ToString(); detail.Product = this.productManager.Get((f.SelectedItem as Model.Product).ProductId); detail.ProductId = detail.Product.ProductId; detail.OtherCompactCount = 0; detail.OtherCompactPrice = 0; detail.InDepotCount = 0; detail.OtherCompactMoney = 0; detail.ProductUnit = detail.Product.DepotUnit == null ? null : detail.Product.DepotUnit.CnName; Model.BomParentPartInfo bompar = this.bomParentPartInfoManager.Get(detail.Product); if (bompar != null) { foreach (Model.BomComponentInfo comm in this.bomComponentInfoManager.Select(bompar)) { Model.ProduceOtherCompactMaterial mater = new Model.ProduceOtherCompactMaterial(); mater.ProduceOtherCompactMaterialId = Guid.NewGuid().ToString(); mater.Product = comm.Product; mater.ProductId = comm.ProductId; mater.ProductUnit = comm.Unit; mater.ProduceQuantity = 0; mater.ParentProduct = product; mater.ParentProductId = product.ProductId; this._produceOtherCompact.DetailMaterial.Add(mater); } } // detail.Inumber = this._produceOtherMaterial.Details.Count + 1; //detail.ProductUnit = detail.Product.MainUnit == null ? null : detail.Product.MainUnit.CnName; detail.ProductSpecification = (f.SelectedItem as Model.Product).ProductSpecification; detail.Inumber = this._produceOtherCompact.Details.Count + 1; this._produceOtherCompact.Details.Add(detail); } this.bindingSourceDetails.Position = this.bindingSourceDetails.IndexOf(detail); //this.bindingSourceMaterial.Position = this.bindingSourceMaterial.IndexOf(detail); this.gridControl1.RefreshDataSource(); this.gridControl2.RefreshDataSource(); } f.Dispose(); System.GC.Collect(); //if (f.ShowDialog(this) == DialogResult.OK) //{ // Model.Product product = f.SelectedItem as Model.Product; // Model.ProduceOtherCompactDetail detail = new Book.Model.ProduceOtherCompactDetail(); // detail.OtherCompactDetailId = Guid.NewGuid().ToString(); // detail.Product = f.SelectedItem as Model.Product; // detail.ProductId = (f.SelectedItem as Model.Product).ProductId; // detail.OtherCompactCount = 0; // detail.OtherCompactPrice = 0; // detail.InDepotCount = 0; // detail.OtherCompactMoney = 0; // //detail.ProductUnit = detail.Product.MainUnit == null ? null : detail.Product.MainUnit.CnName; // detail.ProductSpecification = (f.SelectedItem as Model.Product).ProductSpecification; // this._produceOtherCompact.Details.Add(detail); // this.bindingSourceDetails.Position = this.bindingSourceDetails.IndexOf(detail); // this.gridControl1.RefreshDataSource(); //} }
protected override void AddNew() { this._produceOtherCompact = new Model.ProduceOtherCompact(); this._produceOtherCompact.ProduceOtherCompactDate = DateTime.Now; this._produceOtherCompact.ProduceOtherCompactId = this.produceOtherCompactManager.GetId();// Guid.NewGuid().ToString(); this._produceOtherCompact.Employee0 = BL.V.ActiveOperator.Employee; this._produceOtherCompact.Details = new List <Model.ProduceOtherCompactDetail>(); this._produceOtherCompact.DetailMaterial = new List <Model.ProduceOtherCompactMaterial>(); this._produceOtherCompact.TempMaterials = new List <Model.ProduceOtherCompactMaterial>(); //if (this.action == "insert") //{ //Model.ProduceOtherCompactDetail detail = new Model.ProduceOtherCompactDetail(); //detail.OtherCompactDetailId = Guid.NewGuid().ToString(); //detail.OtherCompactCount = 0; //detail.OtherCompactPrice = 0; //detail.InDepotCount = 0; //detail.OtherCompactMoney = 0; //detail.ProductSpecification = ""; //detail.Product = new Book.Model.Product(); //this.produceOtherCompact.Details.Add(detail); //this.bindingSourceDetails.Position = this.bindingSourceDetails.IndexOf(detail); // } if (this._mrsheader != null) { foreach (Model.MRSdetails mrsdetail in _mrsheader.Details) { this._produceOtherCompactDetail = new Book.Model.ProduceOtherCompactDetail(); this._produceOtherCompactDetail.OtherCompactDetailId = Guid.NewGuid().ToString(); this._produceOtherCompactDetail.OtherCompactCount = mrsdetail.MRSdetailssum; this._produceOtherCompactDetail.Product = mrsdetail.Product; this._produceOtherCompactDetail.ProductId = mrsdetail.Product.ProductId; this._produceOtherCompactDetail.ProductUnit = mrsdetail.ProductUnit; this._produceOtherCompact.Details.Add(this._produceOtherCompactDetail); } foreach (Model.MRSdetails mrsdetail in _mrsheader.Details) { foreach (Model.BomComponentInfo com in this.bomComponentInfoManager.Select(this.bomParentPartInfoManager.Get(mrsdetail.Product))) { this._produceOtherCompactMaterial = new Book.Model.ProduceOtherCompactMaterial(); this._produceOtherCompactMaterial.ProduceQuantity = mrsdetail.MRSdetailssum * com.UseQuantity; this._produceOtherCompactMaterial.Product = com.Product; this._produceOtherCompactMaterial.ProductId = com.Product.ProductId; this._produceOtherCompactMaterial.ProductUnit = com.Unit; this._produceOtherCompact.TempMaterials.Add(this._produceOtherCompactMaterial); } } var materials = from m in this._produceOtherCompact.TempMaterials group m by new { m.ProductId, m.ProductUnit } into g select new { ProduceQuantity = (from x in g select x.ProduceQuantity).Sum(), ProductId = g.Key.ProductId, ProductUnit = g.Key.ProductUnit, stock = g.Max(p => p.Product.StocksQuantity) }; foreach (var item in materials) { this._produceOtherCompactMaterial = new Book.Model.ProduceOtherCompactMaterial(); this._produceOtherCompactMaterial.ProduceOtherCompactMaterialId = Guid.NewGuid().ToString(); this._produceOtherCompactMaterial.ProduceQuantity = item.ProduceQuantity; this._produceOtherCompactMaterial.ProductId = item.ProductId; this._produceOtherCompactMaterial.ProductUnit = item.ProductUnit; this._produceOtherCompact.DetailMaterial.Add(this._produceOtherCompactMaterial); } } }
/// <summary> /// Update a ProduceOtherInDepot. /// </summary> public void Update(Model.ProduceOtherInDepot produceOtherInDepot) { // // todo: add other logic here. // Validate(produceOtherInDepot); try { BL.V.BeginTransaction(); if (produceOtherInDepot != null) { //返回 CancelAffect(produceOtherInDepot, 0); //修改头 produceOtherInDepot.UpdateTime = DateTime.Now; accessor.Update(produceOtherInDepot); //删除详细 ProduceOtherInDepotDetailAccessor.Delete(produceOtherInDepot); //添加详细 foreach (Model.ProduceOtherInDepotDetail produceOtherInDepotDetail in produceOtherInDepot.Details) { if (produceOtherInDepotDetail.Product == null || string.IsNullOrEmpty(produceOtherInDepotDetail.Product.ProductId)) { continue; } produceOtherInDepotDetail.ProduceOtherInDepotId = produceOtherInDepot.ProduceOtherInDepotId; ProduceOtherInDepotDetailAccessor.Insert(produceOtherInDepotDetail); if (!string.IsNullOrEmpty(produceOtherInDepotDetail.DepotPositionId)) { stockAccessor.Increment(new BL.DepotPositionManager().Get(produceOtherInDepotDetail.DepotPositionId), produceOtherInDepotDetail.Product, produceOtherInDepotDetail.ProduceInDepotQuantity); productManager.UpdateProduct_Stock(produceOtherInDepotDetail.Product); } Model.ProduceOtherCompactDetail CompactDetail = produceOtherCompactDetailAccessor.Get(produceOtherInDepotDetail.ProduceOtherCompactDetailId); if (CompactDetail != null) { if (CompactDetail.InDepotCount == null) { CompactDetail.InDepotCount = 0; } CompactDetail.InDepotCount += produceOtherInDepotDetail.ProduceQuantity; if (CompactDetail.InDepotCount >= CompactDetail.OtherCompactCount) { CompactDetail.DetailsFlag = 2; } else { if (CompactDetail.InDepotCount > 0) { CompactDetail.DetailsFlag = 1; } else { CompactDetail.DetailsFlag = 0; } } //进货数量 if (CompactDetail.ArrivalInQuantity == null) { CompactDetail.ArrivalInQuantity = 0; } CompactDetail.ArrivalInQuantity += produceOtherInDepotDetail.ProduceQuantity; produceOtherCompactDetailAccessor.Update(CompactDetail); UpdateProduceOtherCompactFlag(CompactDetail.ProduceOtherCompact); } } } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
/// <summary> /// Insert a ProduceOtherInDepot. /// </summary> public void Insert(Model.ProduceOtherInDepot produceOtherInDepot) { // // todo:add other logic here // Validate(produceOtherInDepot); try { produceOtherInDepot.InsertTime = DateTime.Now; produceOtherInDepot.UpdateTime = DateTime.Now; TiGuiExists(produceOtherInDepot); BL.V.BeginTransaction(); string invoiceKind = this.GetInvoiceKind().ToLower(); string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, produceOtherInDepot.InsertTime.Value.Year); string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, produceOtherInDepot.InsertTime.Value.Year, produceOtherInDepot.InsertTime.Value.Month); string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, produceOtherInDepot.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(produceOtherInDepot); foreach (Model.ProduceOtherInDepotDetail produceOtherInDepotDetail in produceOtherInDepot.Details) { if (produceOtherInDepotDetail.Product == null || string.IsNullOrEmpty(produceOtherInDepotDetail.Product.ProductId)) { throw new Exception("貨品不為空"); } produceOtherInDepotDetail.ProduceOtherInDepotId = produceOtherInDepot.ProduceOtherInDepotId; ProduceOtherInDepotDetailAccessor.Insert(produceOtherInDepotDetail); if (!string.IsNullOrEmpty(produceOtherInDepotDetail.DepotPositionId)) { //Model.Stock stock = stockAccessor.GetStockByProductIdAndDepotPositionId(produceOtherInDepotDetail.ProductId, produceOtherInDepotDetail.DepotPositionId); stockAccessor.Increment(new BL.DepotPositionManager().Get(produceOtherInDepotDetail.DepotPositionId), produceOtherInDepotDetail.Product, produceOtherInDepotDetail.ProduceInDepotQuantity); productManager.UpdateProduct_Stock(produceOtherInDepotDetail.Product); } Model.ProduceOtherCompactDetail CompactDetail = produceOtherCompactDetailAccessor.Get(produceOtherInDepotDetail.ProduceOtherCompactDetailId); if (CompactDetail != null) { if (CompactDetail.InDepotCount == null) { CompactDetail.InDepotCount = 0; } CompactDetail.InDepotCount += produceOtherInDepotDetail.ProduceQuantity; if (CompactDetail.InDepotCount >= CompactDetail.OtherCompactCount) { CompactDetail.DetailsFlag = 2; } else { if (CompactDetail.InDepotCount > 0) { CompactDetail.DetailsFlag = 1; } else { CompactDetail.DetailsFlag = 0; } } //进货数量 if (CompactDetail.ArrivalInQuantity == null) { CompactDetail.ArrivalInQuantity = 0; } CompactDetail.ArrivalInQuantity += produceOtherInDepotDetail.ProduceQuantity; produceOtherCompactDetailAccessor.Update(CompactDetail); UpdateProduceOtherCompactFlag(CompactDetail.ProduceOtherCompact); } } BL.V.CommitTransaction(); } catch { BL.V.RollbackTransaction(); throw; } }
public void Insert(Model.ProduceOtherCompactDetail e) { this.Insert <Model.ProduceOtherCompactDetail>(e); }
public void Update(Model.ProduceOtherCompactDetail e) { this.Update <Model.ProduceOtherCompactDetail>(e); }