/// <summary> /// Insert a InvoiceCODetail. /// </summary> public void Insert(Model.InvoiceCODetail invoiceCODetail) { // // todo:add other logic here // accessor.Insert(invoiceCODetail); }
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.ListSourceRowIndex < 0) { return; } IList <Model.InvoiceCTDetail> details = this.bindingSourceDetail.DataSource as IList <Model.InvoiceCTDetail>; if (details == null || details.Count < 1) { return; } Model.InvoiceCODetail codetail = details[e.ListSourceRowIndex].InvoiceCODetail; if (codetail == null) { return; } switch (e.Column.Name) { //case "colProductId": // e.DisplayText = string.IsNullOrEmpty(detail.Id) ? "" : detail.Id; // break; case "gridColumnCOquantity": e.DisplayText = codetail.OrderQuantity.ToString(); break; default: break; } }
private void gridViewDetail_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.Column.Name == "gridColumnCheck") { Model.InvoiceCODetail detail = this.gridViewDetail.GetRow(e.RowHandle) as Model.InvoiceCODetail; 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].InvoiceCODetailId == detail.InvoiceCODetailId) { key.RemoveAt(i); break; } } // MrsDetails.Remove(this.mRSdetailsManager.Get(detail.MRSdetailsId)); } } }
private void btn_InvoiceCO_Click(object sender, EventArgs e) { Invoices.CG.CGForm f = new Book.UI.Invoices.CG.CGForm(); if (f.ShowDialog(this) == DialogResult.OK) { if (f.key.Count == 0) { return; } Model.InvoiceCODetail coDetail = f.key[0]; if (coDetail != null) { this._pcfog.PronoteHeaderId = coDetail.InvoiceId; this._pcfog.InvoiceCusXOId = coDetail.Invoice.InvoiceCustomXOId; this._pcfog.Product = new BL.ProductManager().Get(coDetail.ProductId); this._pcfog.ProductId = coDetail.ProductId; this._pcfog.mCheckStandard = (coDetail.Invoice.Customer == null ? "" : coDetail.Invoice.Customer.CheckedStandard); this._pcfog.InvoiceXOQuantity = coDetail.OrderQuantity; this._pcfog.ProductUnit = this._pcfog.Product.BuyUnit; this._pcfog.ProductUnitId = this._pcfog.Product.BuyUnitId; this.Refresh(); } } f.Dispose(); GC.Collect(); }
public void UpdateYidingweiru(Model.InvoiceCODetail codetail, double quantity)//要进量 已定未入 { //detail1.UpQuantity = detail1.Quantity - beeQuantity; //Model.BGHandbookDetail1 detail1 = bindingSource1.Current as Model.BGHandbookDetail1; IList <Model.BGHandbookDetail2> _bGHandbookList = Detail2Accessor.SelectbyShouceandId(codetail.HandbookId, codetail.HandbookProductId); if (_bGHandbookList == null) { return; } foreach (Model.BGHandbookDetail2 detail2 in _bGHandbookList) { //多单据 if (!detail2.YaoJInQuantity.HasValue) { detail2.YaoJInQuantity = 0; } if (!detail2.UpQuantity.HasValue) { detail2.UpQuantity = 0; } detail2.YaoJInQuantity = detail2.YaoJInQuantity + quantity; detail2.HaiKeJInQuantity = detail2.UpQuantity - detail2.YaoJInQuantity; Detail2Accessor.Update(detail2); } }
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 gridView3_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { if (e.ListSourceRowIndex < 0) { return; } IList <Model.InvoiceCGDetail> details = this.bindingSource1.DataSource as IList <Model.InvoiceCGDetail>; if (details == null || details.Count < 1) { return; } Model.Product detail = details[e.ListSourceRowIndex].Product; Model.InvoiceCODetail codetail = details[e.ListSourceRowIndex].InvoiceCODetail; switch (e.Column.Name) { case "colProductId": if (detail == null) { return; } e.DisplayText = detail.Id; break; case "gridColumn18": if (codetail != null) { e.DisplayText = codetail.NoArrivalQuantity.Value.ToString("0.####"); } break; case "gridColumn17": if (codetail != null) { e.DisplayText = codetail.OrderQuantity.Value.ToString(); } break; } }
private void _Insert(Model.InvoiceCG invoice) { // Model.InvoiceCO invoiceCO = invoice.InvoiceCO; //修改订单状态 _ValidateForInsert(invoice); if (this.HasRows(invoice.InvoiceId)) { throw new Helper.InvalidValueException(Model.InvoiceCG.PRO_InvoiceCOId); } // int flag = 0; //foreach (Model.InvoiceCGDetail detail in invoice.Details) //{ // if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) continue; // if (!string.IsNullOrEmpty( detail.DepotPositionId)) // flag=1; //} //if(flag==0) // throw new Helper.RequireValueException(Model.InvoiceCGDetail.PRO_DepotPositionId); if (invoice.Employee0 == null) { throw new Helper.MessageValueException("操作員不能為空!"); } invoice.SupplierId = invoice.Supplier.SupplierId; if (invoice.Depot != null) { invoice.DepotId = invoice.Depot.DepotId; } invoice.Employee0Id = invoice.Employee0.EmployeeId; invoice.Employee1Id = invoice.Employee1 == null ? null : invoice.Employee1.EmployeeId; //过账人 invoice.Employee2Id = invoice.Employee2 == null ? null : invoice.Employee2.EmployeeId; //过账时间 invoice.InvoiceGZTime = DateTime.Now; invoice.InvoiceLRTime = DateTime.Now; accessor.Insert(invoice); foreach (Model.InvoiceCGDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } Model.Product p = productAccessor.Get(detail.ProductId); detail.InvoiceId = invoice.InvoiceId; detail.DepotPositionId = detail.DepotPositionId; invoiceCGDetailAccessor.Insert(detail); Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId); if (codetail != null) { //if (detail.InvoiceCGDetailQuantity > codetail.NoArrivalQuantity) //{ // throw new Helper.InvalidValueException("CGQgtCOQ"); //} //进货量大于订单数量 修改订单数量 if (detail.InvoiceCGDetailQuantity >= codetail.NoArrivalQuantity) { //invoiceCO.InvoiceHeji-=codetail.InvoiceCODetailMoney; codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived; // codetail.OrderQuantity = detail.InvoiceCGDetailQuantity + codetail.ArrivalQuantity; // codetail.InvoiceCODetailMoney = codetail.InvoiceCODetailPrice *decimal.Parse(codetail.OrderQuantity.Value.ToString()); // codetail.TotalMoney = codetail.InvoiceCODetailMoney; // invoiceCO.InvoiceHeji += codetail.InvoiceCODetailMoney; //暂时 未考虑税率 // invoiceCO.InvoiceTotal = invoiceCO.InvoiceHeji; } else { if (codetail.ArrivalQuantity == 0) { codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay; } else { codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived; } } codetail.ArrivalQuantity = Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(detail.InvoiceCGDetailQuantity); double noArr = codetail.NoArrivalQuantity.Value; codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity); codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity; invoiceCODetailAccessor.Update(codetail); this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice); //修改手册要进量 if (!string.IsNullOrEmpty(detail.HandbookProductId) && !string.IsNullOrEmpty(detail.HandbookId)) { bGHandbookDetail1Manager.UpdateYidingweiru(codetail, 0 - (noArr - codetail.NoArrivalQuantity.Value)); } //p.OrderOnWayQuantity += codetail.NoArrivalQuantity.Value - noArr; } //更新产品信息00 if (!string.IsNullOrEmpty(detail.InvoiceCODetailId)) { p.OrderOnWayQuantity = Convert.ToDouble(p.OrderOnWayQuantity) - Convert.ToDouble(detail.InvoiceCGDetailQuantity); } //2017年7月24日00:07:10: 可以为负,否则会导致不准 //p.OrderOnWayQuantity = p.OrderOnWayQuantity < 0 ? 0 : p.OrderOnWayQuantity; p.ProductNearCGDate = DateTime.Now; if (codetail != null)//单价 以后 在进库单 保存 { p.NewestCost = codetail.InvoiceCODetailPrice.HasValue ? codetail.InvoiceCODetailPrice.Value : 0; } if (!string.IsNullOrEmpty(detail.DepotPositionId) && detail.InvoiceCGDetaiInQuantity != 0) { p.StocksQuantity = Convert.ToDouble(p.StocksQuantity) + detail.InvoiceCGDetaiInQuantity; //修改货位库存。 stockAccessor.Increment(detail.DepotPosition, p, detail.InvoiceCGDetaiInQuantity); } // 成本 // productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice,cgQuantity); productManager.update(p); //修改手册已进 if (!string.IsNullOrEmpty(detail.HandbookProductId) && !string.IsNullOrEmpty(detail.HandbookId)) { bGHandbookDetail1Manager.UpdateBeeIn(detail.HandbookId, detail.HandbookProductId, detail.InvoiceCGDetailQuantity.Value); } } //应收应付 //companyAccessor.IncrementP(invoice.Company, invoice.InvoiceOwed.Value); }
private void _Update(Model.InvoiceCT invoice) { _ValidateForUpdate(invoice); Model.InvoiceCT invoiceOriginal = this.Get(invoice.InvoiceId); switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus) { case Helper.InvoiceStatus.Draft: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: invoice.UpdateTime = DateTime.Now; invoice.SupplierId = invoice.Supplier.SupplierId; //invoice.DepotId = invoice.Depot.DepotId; invoice.Employee0Id = invoice.Employee0.EmployeeId; accessor.Update(invoice); invoiceCTDetailAccessor.Delete(invoice); foreach (Model.InvoiceCTDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceCTDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoiceCTDetailAccessor.Insert(detail); } break; case Helper.InvoiceStatus.Normal: accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } break; case Helper.InvoiceStatus.Normal: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: throw new InvalidOperationException(); case Helper.InvoiceStatus.Normal: invoiceOriginal.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _TurnNull(invoiceOriginal); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: foreach (Model.InvoiceCTDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } Model.Product p = productAccessor.Get(detail.ProductId); if (!string.IsNullOrEmpty(detail.DepotPositionId)) { stockAccessor.Increment(new DepotPositionManager().Get(detail.DepotPositionId), detail.Product, detail.InvoiceCTDetailQuantity.Value); p.StocksQuantity = Convert.ToDouble(p.StocksQuantity) + Convert.ToDouble(detail.InvoiceCTDetailQuantity); // productAccessor.UpdateProduct_Stock(detail.Product); } Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId); if (codetail != null) { codetail.InvoiceCTQuantity = Convert.ToDouble(codetail.InvoiceCTQuantity) - Convert.ToDouble(detail.InvoiceCTDetailQuantity); codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity); codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity; //进货量大于订单数量 修改订单数量 if (detail.InvoiceCTDetailQuantity >= codetail.NoArrivalQuantity) { codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived; } else { if (codetail.ArrivalQuantity == 0) { codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay; } else { codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived; } } invoiceCODetailAccessor.Update(codetail); if (!p.OrderOnWayQuantity.HasValue) { p.OrderOnWayQuantity = 0; } p.OrderOnWayQuantity = Convert.ToDouble(p.OrderOnWayQuantity) - Convert.ToDouble(detail.InvoiceCTDetailQuantity); // this.UpdateSql("update product set OrderOnWayQuantity=OrderOnWayQuantity-" + detail.InvoiceCTDetailQuantity + " where productid='" + codetail.ProductId + "'"); this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice); } productAccessor.Update(p); //if (detail.InvoiceProductUnit == detail.Product.ProductOuterPackagingUnit) //{ // p.ProductCurrentCGPrice = detail.InvoiceCTDetailPrice / Convert.ToDecimal(p.ProductBaseUnitRelationship.Value) / Convert.ToDecimal(p.ProductInnerUnitRelationship.Value); // cgQuantity = detail.InvoiceCTDetailQuantity * p.ProductBaseUnitRelationship * p.ProductInnerUnitRelationship; //} //else if (detail.InvoiceProductUnit == detail.Product.ProductInnerPackagingUnit) //{ // p.ProductCurrentCGPrice = detail.InvoiceCTDetailPrice / Convert.ToDecimal(p.ProductBaseUnitRelationship.Value); // cgQuantity = detail.InvoiceCTDetailQuantity * p.ProductBaseUnitRelationship; //} //else //{ // p.ProductCurrentCGPrice = detail.InvoiceCTDetailPrice; // cgQuantity = detail.InvoiceCTDetailQuantity; //} //productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice, cgQuantity); //stockAccessor.Increment(invoice.Depot, p,z.Value); } //companyAccessor.IncrementP(invoice.Company, invoice.InvoiceOwed.Value); break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
private void _Insert(Model.InvoiceCT invoice) { _ValidateForInsert(invoice); invoice.SupplierId = invoice.Supplier.SupplierId; invoice.Employee0Id = invoice.Employee0.EmployeeId; invoice.Employee1Id = invoice.Employee1 == null ? null : invoice.Employee1.EmployeeId; if (invoice.InvoiceStatus == (int)Helper.InvoiceStatus.Normal) { invoice.InvoiceGZTime = DateTime.Now;; //过账人 invoice.Employee2Id = invoice.Employee2 == null ? null : invoice.Employee2.EmployeeId; } accessor.Insert(invoice); //Model.Depot depot = invoice.Depot; // 库存 foreach (Model.InvoiceCTDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } Model.Product p = productAccessor.Get(detail.ProductId); detail.InvoiceId = invoice.InvoiceId; invoiceCTDetailAccessor.Insert(detail); // p.ProductNearCGDate = DateTime.Now; if (!string.IsNullOrEmpty(detail.DepotPositionId)) { stockAccessor.Decrement(new DepotPositionManager().Get(detail.DepotPositionId), detail.Product, detail.InvoiceCTDetailQuantity.Value); p.StocksQuantity = Convert.ToDouble(p.StocksQuantity) - Convert.ToDouble(detail.InvoiceCTDetailQuantity); // productAccessor.UpdateProduct_Stock(detail.Product); } Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId); if (codetail != null) { //if (detail.InvoiceCGDetailQuantity > codetail.NoArrivalQuantity) //{ // throw new Helper.InvalidValueException("CGQgtCOQ"); //} //进货量大于订单数量 修改订单数量 if (detail.InvoiceCTDetailQuantity >= codetail.NoArrivalQuantity) { codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived; } else { if (codetail.ArrivalQuantity == 0) { codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay; } else { codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived; } } codetail.InvoiceCTQuantity = Convert.ToDouble(codetail.InvoiceCTQuantity) + Convert.ToDouble(detail.InvoiceCTDetailQuantity); codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity); codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity; invoiceCODetailAccessor.Update(codetail); this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice); if (!p.OrderOnWayQuantity.HasValue) { p.OrderOnWayQuantity = 0; } p.OrderOnWayQuantity = Convert.ToDouble(p.OrderOnWayQuantity) + Convert.ToDouble(detail.InvoiceCTDetailQuantity); } productAccessor.Update(p); // 成本 //productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice, -cgQuantity); // 库存 //stockAccessor.Decrement(invoice.Depot, detail.Product, cgQuantity.Value); } // 应付 //companyAccessor.DecrementP(invoice.Company, invoice.InvoiceOwed.Value); }
public void Update(Model.InvoiceCODetail e) { this.Update <Model.InvoiceCODetail>(e); }
/// <summary> /// 单价校对修改 /// </summary> public void UpdateProofUnitPrice(Model.InvoiceCODetail e) { //修改详细 accessor.UpdateProofUnitPrice(e); }
/// <summary> /// Update a InvoiceCODetail. /// </summary> public void Update(Model.InvoiceCODetail invoiceCODetail) { accessor.Update(invoiceCODetail); }
/// <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 _Insert(Model.InvoiceCG invoice) { // Model.InvoiceCO invoiceCO = invoice.InvoiceCO; //修改订单状态 _ValidateForInsert(invoice); if (this.HasRows(invoice.InvoiceId)) { throw new Helper.InvalidValueException(Model.InvoiceCG.PRO_InvoiceCOId); } // int flag = 0; //foreach (Model.InvoiceCGDetail detail in invoice.Details) //{ // if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) continue; // if (!string.IsNullOrEmpty( detail.DepotPositionId)) // flag=1; //} //if(flag==0) // throw new Helper.RequireValueException(Model.InvoiceCGDetail.PRO_DepotPositionId); if (invoice.Employee0 == null) { throw new Helper.MessageValueException("Attn can not be empty!"); } invoice.SupplierId = invoice.Supplier.SupplierId; if (invoice.Depot != null) { invoice.DepotId = invoice.Depot.DepotId; } invoice.Employee0Id = invoice.Employee0.EmployeeId; invoice.Employee1Id = invoice.Employee1 == null ? null : invoice.Employee1.EmployeeId; //过账人 invoice.Employee2Id = invoice.Employee2 == null ? null : invoice.Employee2.EmployeeId; //过账时间 invoice.InvoiceGZTime = DateTime.Now; invoice.InvoiceLRTime = DateTime.Now; accessor.Insert(invoice); foreach (Model.InvoiceCGDetail detail in invoice.Details) { //if (detail.InvoiceCGDetaiInQuantity + invoiceCGDetailAccessor.CountInDepotQuantity(detail.InvoiceCODetailId) > detail.OrderQuantity) // throw new Helper.MessageValueException("序號: " + (detail.Inumber == null ? "" : detail.Inumber.ToString()) + " 總入庫數量大于訂貨數量!"); if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } Model.Product p = productAccessor.Get(detail.ProductId); detail.InvoiceId = invoice.InvoiceId; detail.DepotPositionId = detail.DepotPositionId; invoiceCGDetailAccessor.Insert(detail); Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId); if (codetail != null) { //if (detail.InvoiceCGDetailQuantity > codetail.NoArrivalQuantity) //{ // throw new Helper.InvalidValueException("CGQgtCOQ"); //} //进货量大于订单数量 修改订单数量 //if (detail.InvoiceCGDetailQuantity >= codetail.NoArrivalQuantity) //{ // //invoiceCO.InvoiceHeji-=codetail.InvoiceCODetailMoney; // codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived; // // codetail.OrderQuantity = detail.InvoiceCGDetailQuantity + codetail.ArrivalQuantity; // // codetail.InvoiceCODetailMoney = codetail.InvoiceCODetailPrice *decimal.Parse(codetail.OrderQuantity.Value.ToString()); // // codetail.TotalMoney = codetail.InvoiceCODetailMoney; // // invoiceCO.InvoiceHeji += codetail.InvoiceCODetailMoney; // //暂时 未考虑税率 // // invoiceCO.InvoiceTotal = invoiceCO.InvoiceHeji; //} //else //{ // if (codetail.ArrivalQuantity == 0) // { codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay; } // else // codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived; //} codetail.ArrivalQuantity = Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(detail.InvoiceCGDetailQuantity); codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity); codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity; if (codetail.NoArrivalQuantity == 0) { codetail.DetailsFlag = (int)Helper.DetailsFlag.AllArrived; } else if (codetail.ArrivalQuantity == 0) { codetail.DetailsFlag = (int)Helper.DetailsFlag.OnTheWay; } else { codetail.DetailsFlag = (int)Helper.DetailsFlag.PartArrived; } invoiceCODetailAccessor.Update(codetail); this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice); } //更新产品信息00 p.OrderOnWayQuantity = Convert.ToDouble(p.OrderOnWayQuantity) - Convert.ToDouble(detail.InvoiceCGDetailQuantity); p.OrderOnWayQuantity = p.OrderOnWayQuantity < 0 ? 0 : p.OrderOnWayQuantity; p.ProductNearCGDate = DateTime.Now; if (codetail != null)//单价 以后 在进库单 保存 { p.NewestCost = codetail.InvoiceCODetailPrice.HasValue ? codetail.InvoiceCODetailPrice.Value : 0; } if (!string.IsNullOrEmpty(detail.DepotPositionId) && detail.InvoiceCGDetaiInQuantity != 0) { p.StocksQuantity = Convert.ToDouble(p.StocksQuantity) + Convert.ToDouble(detail.InvoiceCGDetaiInQuantity); //修改货位库存。 stockAccessor.Increment(detail.DepotPosition, p, detail.InvoiceCGDetaiInQuantity); } // 成本 // productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice,cgQuantity); productManager.update(p); } //应收应付 //companyAccessor.IncrementP(invoice.Company, invoice.InvoiceOwed.Value); }
public void Insert(Model.InvoiceCODetail e) { this.Insert <Model.InvoiceCODetail>(e); }
private void _Update(Model.InvoiceCG invoice) { _ValidateForUpdate(invoice); invoice.UpdateTime = DateTime.Now; Model.InvoiceCG invoiceOriginal = this.Get(invoice.InvoiceId); switch ((Helper.InvoiceStatus)invoiceOriginal.InvoiceStatus) { case Helper.InvoiceStatus.Draft: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: invoice.UpdateTime = DateTime.Now; invoice.SupplierId = invoice.Supplier.SupplierId; invoice.DepotId = invoice.Depot.DepotId; invoice.Employee0Id = invoice.Employee0.EmployeeId; accessor.Update(invoice); invoiceCGDetailAccessor.Delete(invoiceOriginal); foreach (Model.InvoiceCGDetail detail in invoice.Details) { if (detail.Product == null || string.IsNullOrEmpty(detail.Product.ProductId)) { continue; } detail.InvoiceCGDetailId = Guid.NewGuid().ToString(); detail.InvoiceId = invoice.InvoiceId; invoiceCGDetailAccessor.Insert(detail); } break; case Helper.InvoiceStatus.Normal: accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } break; case Helper.InvoiceStatus.Normal: switch ((Helper.InvoiceStatus)invoice.InvoiceStatus) { case Helper.InvoiceStatus.Draft: throw new InvalidOperationException(); case Helper.InvoiceStatus.Normal: invoiceOriginal.InvoiceStatus = (int)Helper.InvoiceStatus.Null; _TurnNull(invoiceOriginal); accessor.Delete(invoiceOriginal.InvoiceId); invoice.InsertTime = invoiceOriginal.InsertTime; invoice.UpdateTime = DateTime.Now; _Insert(invoice); break; case Helper.InvoiceStatus.Null: foreach (Model.InvoiceCGDetail detail in invoice.Details) { //修改订单未到和实际到数量 Model.InvoiceCODetail codetail = invoiceCODetailAccessor.Get(detail.InvoiceCODetailId); if (codetail != null) { codetail.ArrivalQuantity = Convert.ToDouble(codetail.ArrivalQuantity) - Convert.ToDouble(detail.InvoiceCGDetailQuantity); codetail.NoArrivalQuantity = Convert.ToDouble(codetail.OrderQuantity) - Convert.ToDouble(codetail.ArrivalQuantity) + Convert.ToDouble(codetail.InvoiceCTQuantity); codetail.NoArrivalQuantity = codetail.NoArrivalQuantity < 0 ? 0 : codetail.NoArrivalQuantity; if (codetail.NoArrivalQuantity < 0) { codetail.NoArrivalQuantity = 0; } if (codetail.NoArrivalQuantity == 0) { codetail.DetailsFlag = 2; } else if (codetail.NoArrivalQuantity == codetail.OrderQuantity) { codetail.DetailsFlag = 0; } else { codetail.DetailsFlag = 1; } invoiceCODetailAccessor.Update(codetail); this.invoiceCOManager.UpdateInvoiceFlag(codetail.Invoice); } //更新产品信息 //if (detail.DepotPosition != null) //{ Model.Product pro = detail.Product; pro.OrderOnWayQuantity = Convert.ToDouble(pro.OrderOnWayQuantity) + Convert.ToDouble(detail.InvoiceCGDetailQuantity); pro.ProductNearCGDate = DateTime.Now; if (!string.IsNullOrEmpty(detail.DepotPositionId) && detail.InvoiceCGDetaiInQuantity != 0) { pro.StocksQuantity = Convert.ToDouble(pro.StocksQuantity) - Convert.ToDouble(detail.InvoiceCGDetaiInQuantity); //修改货位库存。 stockAccessor.Decrement(detail.DepotPosition, pro, detail.InvoiceCGDetaiInQuantity); } productManager.update(pro); //} // 成本 //productAccessor.UpdateCost1(p, p.ProductCurrentCGPrice,cgQuantity); } // this.invoiceCOManager.UpdateInvoiceFlag(invoice.InvoiceCO); //应收应付 //companyAccessor.IncrementP(invoice.Company, invoice.InvoiceOwed.Value); break; } break; case Helper.InvoiceStatus.Null: throw new InvalidOperationException(); } }
/// <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); } } } } }