public JsonResult AddPurchaseDetail(int movement, int warehouse, int product) { var p = Product.Find (product); var cost = (from x in ProductPrice.Queryable where x.Product.Id == product && x.List.Id == 0 select x.Value).SingleOrDefault (); var item = new PurchaseOrderDetail { Order = PurchaseOrder.Find (movement), Warehouse = Warehouse.Find (warehouse), Product = p, ProductCode = p.Code, ProductName = p.Name, Quantity = 1, TaxRate = p.TaxRate, IsTaxIncluded = p.IsTaxIncluded, Discount = 0, Price = cost, ExchangeRate = CashHelpers.GetTodayDefaultExchangeRate (), Currency = WebConfig.DefaultCurrency }; using (var scope = new TransactionScope ()) { item.CreateAndFlush (); } return Json (new { id = item.Id }); }
// PUT api/awbuildversion/5 public void Put(PurchaseOrderDetail value) { var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault(); if (GetActionType.Key != null) { if (GetActionType.Value.ToList()[0].Equals("DELETE")) adventureWorks_BC.PurchaseOrderDetailDelete(value); if (GetActionType.Value.ToList()[0].Equals("UPDATE")) adventureWorks_BC.PurchaseOrderDetailUpdate(value); } }
public string AddOrUpdatePurchaseOrder(int id, int branchID, DateTime date, DateTime expectedDate, int supplierID, string notes, decimal discValue, string terms, List <PurchaseOrderDetailViewModel> detail) { var poHeader = id == 0 ? new PurchaseOrderHeader() : context.PurchaseOrderHeaders.Single(po => po.ID == id); var autoNo = new AutoNumberProvider(context, principal); var emp = new EmployeeProvider(context, principal); if (id == 0) { poHeader.DocumentNo = autoNo.GeneratePurchaseOrderRunningNumber(CurrentCompanyCode, date); } poHeader.BranchID = branchID; poHeader.Date = date; poHeader.ExpectedDate = expectedDate; poHeader.SupplierID = supplierID; poHeader.Notes = notes; poHeader.DiscountValue = discValue; poHeader.Terms = terms; poHeader.EmployeeID = emp.GetEmployee(CurrentUserName).ID; poHeader.Status = "O"; poHeader.StatusReceiving = "O"; EntityHelper.SetAuditFields(id, poHeader, CurrentUserName); //context.SubmitChanges(); context.PurchaseOrderDetails.DeleteAllOnSubmit(poHeader.PurchaseOrderDetails); foreach (var detailLine in detail) { PurchaseOrderDetailViewModel line = detailLine; var itemProvider = new ItemProvider(context, principal); decimal ratio = itemProvider.GetItemUnitRatio(detailLine.ItemID, detailLine.UnitName); var poDetail = new PurchaseOrderDetail { ItemID = detailLine.ItemID, UnitPrice = detailLine.UnitPrice, Quantity = detailLine.Quantity, IsTaxed = detailLine.IsTaxed, DiscountRate = detailLine.DiscountRate, UnitName = detailLine.UnitName, UnitRatio = ratio, Notes = String.Empty }; poDetail.PurchaseOrderHeader = poHeader; //poHeader.PurchaseOrderDetails.Add(poDetail); context.PurchaseOrderDetails.InsertOnSubmit(poDetail); } if (id == 0) { context.PurchaseOrderHeaders.InsertOnSubmit(poHeader); } context.SubmitChanges(); return(poHeader.DocumentNo); }
private void Controller_ObjectCreated(object sender, ObjectCreatedEventArgs e) { ListView lv = ((ListView)View); if (lv.CollectionSource is PropertyCollectionSource) { PropertyCollectionSource collectionSource = (PropertyCollectionSource)lv.CollectionSource; if (collectionSource.MasterObject != null) { int minvalue = 0; int maxvisorder = 0; if (collectionSource.MasterObjectType == typeof(StockTransferRequest) && e.CreatedObject.GetType() == typeof(StockTransferRequestDetail)) { StockTransferRequest masterobject = (StockTransferRequest)collectionSource.MasterObject; StockTransferRequestDetail currentobject = (StockTransferRequestDetail)e.CreatedObject; copyCon.GetStockDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (sDtlS != null) { copyCon.copyClassStockTransferDocumentDetail(sDtlS, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseOrder)) { PurchaseOrder masterobject = (PurchaseOrder)collectionSource.MasterObject; PurchaseOrderDetail currentobject = (PurchaseOrderDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseRequest)) { PurchaseRequest masterobject = (PurchaseRequest)collectionSource.MasterObject; PurchaseRequestDetail currentobject = (PurchaseRequestDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseDelivery)) { PurchaseDelivery masterobject = (PurchaseDelivery)collectionSource.MasterObject; PurchaseDeliveryDetail currentobject = (PurchaseDeliveryDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseReturn)) { PurchaseReturn masterobject = (PurchaseReturn)collectionSource.MasterObject; PurchaseReturnDetail currentobject = (PurchaseReturnDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseQuotation)) { PurchaseQuotation masterobject = (PurchaseQuotation)collectionSource.MasterObject; PurchaseQuotationDetail currentobject = (PurchaseQuotationDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } } } sDtl = null; sDtlS = null; }
public bool isValid(PurchaseOrderDetail obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
public bool ValidConfirmObject(PurchaseOrderDetail purchaseOrderDetail) { purchaseOrderDetail.Errors.Clear(); VConfirmObject(purchaseOrderDetail); return(isValid(purchaseOrderDetail)); }
partial void PurchaseOrderDetails_Validate(PurchaseOrderDetail entity, EntitySetValidationResultsBuilder results) { if (entity.DateRecieved != null & entity.PurchaseOrder.DatePurchaseOrderPlaced != null) { if (entity.DateRecieved < entity.PurchaseOrder.DatePurchaseOrderPlaced) { results.AddEntityError("The purchase order product cannot be recieved before the purchase order is placed"); } } }
public static PurchaseOrderDetail CreatePurchaseOrderDetail(int ID, global::System.DateTime requireDate, int purchaseOrderDetail_Product, int purchaseOrderDetail_Location, double requireQuantity, decimal requireTotalCost, bool isReceiveComplete, int purchaseOrderDetail_PurchaseOrder, byte[] rowVersion) { PurchaseOrderDetail purchaseOrderDetail = new PurchaseOrderDetail(); purchaseOrderDetail.Id = ID; purchaseOrderDetail.RequireDate = requireDate; purchaseOrderDetail.PurchaseOrderDetail_Product = purchaseOrderDetail_Product; purchaseOrderDetail.PurchaseOrderDetail_Location = purchaseOrderDetail_Location; purchaseOrderDetail.RequireQuantity = requireQuantity; purchaseOrderDetail.RequireTotalCost = requireTotalCost; purchaseOrderDetail.IsReceiveComplete = isReceiveComplete; purchaseOrderDetail.PurchaseOrderDetail_PurchaseOrder = purchaseOrderDetail_PurchaseOrder; purchaseOrderDetail.RowVersion = rowVersion; return purchaseOrderDetail; }
/// <summary> /// Update Purchase Order Detail /// </summary> /// <param name="purchaseOrderDetailDataTransformation"></param> /// <returns></returns> public async Task <ResponseModel <PurchaseOrderDetailDataTransformation> > UpdatePurchaseOrderDetail(PurchaseOrderDetailDataTransformation purchaseOrderDetailDataTransformation) { ResponseModel <PurchaseOrderDetailDataTransformation> returnResponse = new ResponseModel <PurchaseOrderDetailDataTransformation>(); PurchaseOrderDetail purchaseOrderDetail = new PurchaseOrderDetail(); try { int accountId = purchaseOrderDetailDataTransformation.AccountId; int purchaseOrderId = purchaseOrderDetailDataTransformation.PurchaseOrderId; int purchaseOrderDetailId = purchaseOrderDetailDataTransformation.PurchaseOrderDetailId; if (purchaseOrderDetailDataTransformation.CurrentReceivedQuantity == 0) { returnResponse.ReturnMessage.Add("Invalid Received Quantity"); returnResponse.ReturnStatus = false; return(returnResponse); } _inventoryManagementDataService.OpenConnection(_connectionStrings.PrimaryDatabaseConnectionString); _inventoryManagementDataService.BeginTransaction((int)IsolationLevel.Serializable); PurchaseOrder purchaseOrder = await _inventoryManagementDataService.GetPurchaseOrderHeader(accountId, purchaseOrderId); if (purchaseOrder == null) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnMessage.Add("Purchase Order not found"); returnResponse.ReturnStatus = false; return(returnResponse); } purchaseOrderDetail = await _inventoryManagementDataService.GetPurchaseOrderDetailForUpdate(purchaseOrderDetailId); if (purchaseOrderDetail == null) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnMessage.Add("Purchase Order Detail not found"); returnResponse.ReturnStatus = false; return(returnResponse); } purchaseOrderDetail.ReceivedQuantity = purchaseOrderDetail.ReceivedQuantity + purchaseOrderDetailDataTransformation.CurrentReceivedQuantity; await _inventoryManagementDataService.UpdatePurchaseOrderDetail(purchaseOrderDetail); Product product = await _inventoryManagementDataService.GetProductInformationForUpdate(purchaseOrderDetail.ProductId); if (product == null) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnMessage.Add("Product not found"); returnResponse.ReturnStatus = false; return(returnResponse); } double newAverageCost = CalculateAverageCost(product.OnHandQuantity, product.AverageCost, purchaseOrderDetailDataTransformation.CurrentReceivedQuantity, purchaseOrderDetail.UnitPrice); if (newAverageCost != 0) { product.AverageCost = newAverageCost; } product.OnHandQuantity = product.OnHandQuantity + purchaseOrderDetailDataTransformation.CurrentReceivedQuantity; await _inventoryManagementDataService.UpdateProduct(product); InventoryTransaction inventoryTransaction = new InventoryTransaction(); inventoryTransaction.EntityId = purchaseOrderDetail.PurchaseOrderDetailId; inventoryTransaction.MasterEntityId = purchaseOrderDetail.MasterPurchaseOrderDetailId; inventoryTransaction.ProductId = purchaseOrderDetail.ProductId; inventoryTransaction.UnitCost = purchaseOrderDetail.UnitPrice; inventoryTransaction.Quantity = purchaseOrderDetailDataTransformation.CurrentReceivedQuantity; inventoryTransaction.TransactionDate = DateTime.UtcNow; await _inventoryManagementDataService.CreateInventoryTransaction(inventoryTransaction); TransactionQueueOutbound transactionQueue = new TransactionQueueOutbound(); transactionQueue.Payload = GenerateInventoryTransactionPayload(inventoryTransaction); transactionQueue.TransactionCode = TransactionQueueTypes.InventoryReceived; transactionQueue.ExchangeName = MessageQueueExchanges.InventoryManagement; await _inventoryManagementDataService.CreateOutboundTransactionQueue(transactionQueue); await _inventoryManagementDataService.UpdateDatabase(); _inventoryManagementDataService.CommitTransaction(); returnResponse.ReturnStatus = true; } catch (Exception ex) { _inventoryManagementDataService.RollbackTransaction(); returnResponse.ReturnStatus = false; returnResponse.ReturnMessage.Add(ex.Message); } finally { _inventoryManagementDataService.CloseConnection(); } returnResponse.Entity = purchaseOrderDetailDataTransformation; return(returnResponse); }
/// <summary> /// 对gridview中数据进行处理,自动生成采购单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGeneratePurchaseRecords_Click(object sender, EventArgs e) { try { this.btnGeneratePurchaseRecords.Enabled = !this.btnGeneratePurchaseRecords.Enabled; if (this.dataGridView1.Rows.Count <= 0) { MessageBox.Show("请选择采购药品", "错误", MessageBoxButtons.OK); this.btnGeneratePurchaseRecords.Enabled = !this.btnGeneratePurchaseRecords.Enabled; return; } string msg = string.Empty; listSupply.Clear(); string OrderNumber = string.Empty; if (GetSupplyList()) { for (int i = 0; i < listSupply.Count; i++) { #region 构造主表 PurchaseOrder order = new PurchaseOrder(); List <PurchaseOrderDetail> orderDetails = new List <PurchaseOrderDetail>(); order.Decription = richTextBox1.Text; if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg); return; } order.SupplyUnitId = Guid.Parse(listSupply[i]); order.CreateUserId = AppClientContext.CurrentUser.Id; order.OrderStatusValue = (int)OrderStatus.Waitting; order.AllReceiptedDate = DateTime.Now; order.DirectMarketing = ckDirectMarketing.Checked; order.ShippingMethod = string.Empty; order.PurchasedDate = DateTime.Now; if (!ckDirectMarketing.Checked) { order.TaxReturnUserID = (Guid)this.comboBox1.SelectedValue; } #endregion #region 构造明细表 for (int j = 0; j < this.dataGridView1.Rows.Count; j++) { if (listSupply[i].Equals(this.dataGridView1.Rows[j].Cells["clmSupplyUnitId"].Value.ToString())) { PurchaseOrderDetail detail = new PurchaseOrderDetail(); detail.sequence = j; detail.AmountOfTax = Convert.ToDecimal(this.dataGridView1.Rows[j].Cells[AmountOfTax.Name].EditedFormattedValue); detail.DrugInfoId = Guid.Parse(this.dataGridView1.Rows[j].Cells["clmDrugId"].Value.ToString()); detail.Amount = Decimal.Parse(this.dataGridView1.Rows[j].Cells["clmDrugNumber"].Value.ToString()); detail.PurchasePrice = decimal.Parse(this.dataGridView1.Rows[j].Cells["clmPurchasePrice"].Value.ToString()); orderDetails.Add(detail); if (detail.AmountOfTax <= 0m || detail.DrugInfoId == Guid.Empty || detail.Amount <= 0m || detail.PurchasePrice < 0m) { MessageBox.Show("第" + (j + 1).ToString() + "行有数据为0,或者小于0,请检查数据!"); this.dataGridView1.Rows[j].Selected = true; return; } if (detail.PurchasePrice == 0m) { if (MessageBox.Show("该行价格为0,如果是赠品(赠品价格允许为0,但不允许为负数),则点击确定;如不是,则请点击取消修改", "提示", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel) { return; } } } } #endregion OrderNumber = this.PharmacyDatabaseService.CreatePurchaseOrder(out msg, order, orderDetails.ToArray()); if (!String.IsNullOrEmpty(msg)) { btnGeneratePurchaseRecords.Enabled = true; MessageBox.Show(msg, "错误", MessageBoxButtons.OK); return; } } MessageBox.Show("采购记录创建成功,单号:" + OrderNumber, "提示", MessageBoxButtons.OK); this.PharmacyDatabaseService.WriteLog(AppClientContext.CurrentUser.Id, "执行采购单生成操作成功,单号:" + OrderNumber); (Parent.FindForm() as frmMain).ShowForm(new FormPurchaseOrderWaittingList()); this.FormClosing -= new FormClosingEventHandler(FormPurchaseOrderGenerator_FormClosing); this.Close(); } } catch (Exception ex) { btnGeneratePurchaseRecords.Enabled = true; MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK); Log.Error(ex); } }
void before_each() { var db = new OffsetPrintingSuppliesEntities(); using (db) { db.DeleteAllTables(); _contactService = new ContactService(new ContactRepository(), new ContactValidator()); _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator()); _purchaseInvoiceService = new PurchaseInvoiceService(new PurchaseInvoiceRepository(), new PurchaseInvoiceValidator()); _purchaseInvoiceDetailService = new PurchaseInvoiceDetailService(new PurchaseInvoiceDetailRepository(), new PurchaseInvoiceDetailValidator()); _purchaseOrderService = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator()); _purchaseOrderDetailService = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator()); _purchaseReceivalService = new PurchaseReceivalService(new PurchaseReceivalRepository(), new PurchaseReceivalValidator()); _purchaseReceivalDetailService = new PurchaseReceivalDetailService(new PurchaseReceivalDetailRepository(), new PurchaseReceivalDetailValidator()); _stockAdjustmentService = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator()); _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator()); _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _uomService = new UoMService(new UoMRepository(), new UoMValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); Pcs = new UoM() { Name = "Pcs" }; _uomService.CreateObject(Pcs); contact = new Contact() { Name = "President of Indonesia", Address = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat", ContactNo = "021 3863777", PIC = "Mr. President", PICContactNo = "021 3863777", Email = "*****@*****.**" }; contact = _contactService.CreateObject(contact); type = _itemTypeService.CreateObject("Item", "Item"); warehouse = new Warehouse() { Name = "Sentral Solusi Data", Description = "Kali Besar Jakarta", Code = "LCL" }; warehouse = _warehouseService.CreateObject(warehouse, _warehouseItemService, _itemService); item_batiktulis = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Batik Tulis", Category = "Item", Sku = "bt123", UoMId = Pcs.Id }; item_batiktulis = _itemService.CreateObject(item_batiktulis, _uomService, _itemTypeService, _warehouseItemService, _warehouseService); _itemService.AdjustQuantity(item_batiktulis, 1000); _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item_batiktulis.Id), 1000); item_busway = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Busway", Category = "Untuk disumbangkan bagi kebutuhan DKI Jakarta", Sku = "DKI002", UoMId = Pcs.Id }; item_busway = _itemService.CreateObject(item_busway, _uomService, _itemTypeService, _warehouseItemService, _warehouseService); _itemService.AdjustQuantity(item_busway, 200); _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item_busway.Id), 200); item_botolaqua = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Botol Aqua", Category = "Minuman", Sku = "DKI003", UoMId = Pcs.Id }; item_botolaqua = _itemService.CreateObject(item_botolaqua, _uomService, _itemTypeService, _warehouseItemService, _warehouseService); _itemService.AdjustQuantity(item_botolaqua, 20000); _warehouseItemService.AdjustQuantity(_warehouseItemService.FindOrCreateObject(warehouse.Id, item_botolaqua.Id), 20000); purchaseOrder1 = _purchaseOrderService.CreateObject(contact.Id, new DateTime(2014, 07, 09), _contactService); purchaseOrder2 = _purchaseOrderService.CreateObject(contact.Id, new DateTime(2014, 04, 09), _contactService); purchaseOrderDetail_batiktulis_so1 = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_batiktulis.Id, 500, 2000000, _purchaseOrderService, _itemService); purchaseOrderDetail_busway_so1 = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_busway.Id, 91, 800000000, _purchaseOrderService, _itemService); purchaseOrderDetail_botolaqua_so1 = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_botolaqua.Id, 2000, 5000, _purchaseOrderService, _itemService); purchaseOrderDetail_batiktulis_so2 = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_batiktulis.Id, 40, 2000500, _purchaseOrderService, _itemService); purchaseOrderDetail_busway_so2 = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_busway.Id, 3, 810000000, _purchaseOrderService, _itemService); purchaseOrderDetail_botolaqua_so2 = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_botolaqua.Id, 340, 5500, _purchaseOrderService, _itemService); purchaseOrder1 = _purchaseOrderService.ConfirmObject(purchaseOrder1, DateTime.Today, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService); purchaseOrder2 = _purchaseOrderService.ConfirmObject(purchaseOrder2, DateTime.Today, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService); } }
partial void PurchaseOrderDetails_Updated(PurchaseOrderDetail entity) { OnProductStatusAffected(entity.Product); }
public List <CurrentOrder> GetCurrentOrder(int vendorid, string username) { using (var context = new eBikesContext()) { if (context.PurchaseOrders.Where(x => x.VendorID == vendorid && x.OrderDate == null).Any()) { var result = from order in context.PurchaseOrderDetails where order.PurchaseOrder.VendorID == vendorid && order.PurchaseOrder.OrderDate == null select new CurrentOrder { PurchaseOrderID = order.PurchaseOrder.PurchaseOrderID, PurchaseOrderDetailID = order.PurchaseOrderDetailID, PartID = order.PartID, Description = order.Part.Description, QOH = order.Part.QuantityOnHand, QOO = order.Part.QuantityOnOrder, ROL = order.Part.ReorderLevel, Buffer = (order.Part.QuantityOnHand + order.Part.QuantityOnOrder) - order.Part.ReorderLevel, Qty = order.Quantity, Price = order.PurchasePrice }; return(result.ToList()); } else { var purchaseOrder = context.PurchaseOrders.Add(new PurchaseOrder()); purchaseOrder.Closed = false; purchaseOrder.VendorID = vendorid; purchaseOrder.Employee = context.Employees.Find(getEmployeeID(username)); var result = from part in context.Parts where part.Vendor.VendorID == vendorid && (part.ReorderLevel - (part.QuantityOnHand + part.QuantityOnOrder)) > 0 select new CurrentOrder { PurchaseOrderID = purchaseOrder.PurchaseOrderID, PartID = part.PartID, Description = part.Description, QOH = part.QuantityOnHand, QOO = part.QuantityOnOrder, ROL = part.ReorderLevel, Buffer = ((part.QuantityOnHand + part.QuantityOnOrder) - part.ReorderLevel) > 0 ? ((part.QuantityOnHand + part.QuantityOnOrder) - part.ReorderLevel) : 0, Qty = part.ReorderLevel - part.QuantityOnHand, Price = part.PurchasePrice }; foreach (var item in result.ToList()) { PurchaseOrderDetail detail = new PurchaseOrderDetail(); detail.PartID = item.PartID; detail.Quantity = item.Qty; detail.PurchasePrice = item.Price; purchaseOrder.PurchaseOrderDetails.Add(detail); purchaseOrder.SubTotal += (item.Qty * item.Price); purchaseOrder.TaxAmount += ((item.Qty * item.Price) * (decimal)0.05); } context.SaveChanges(); return(result.ToList()); } } }
public void PlaceOrder(FinalOrder order) { using (var context = new eBikesContext()) { var updatedOrder = context.PurchaseOrders.Find(order.PurchaseOrderID); var details = context.PurchaseOrderDetails.Where(x => x.PurchaseOrderID == updatedOrder.PurchaseOrderID)?.ToList(); if (order.OrderDetails.Count == 0) { throw new Exception("An empty order cannot be placed. Please, add items to the order."); } else { updatedOrder.OrderDate = DateTime.Today; updatedOrder.PurchaseOrderNumber = context.PurchaseOrders.Max(x => x.PurchaseOrderNumber) + 1; updatedOrder.SubTotal = order.Subtotal; updatedOrder.TaxAmount = order.GST; //going through the original list of details and comparing it with the new one foreach (var item in details) { var changedpart = order.OrderDetails.SingleOrDefault(x => x.PartID == item.PartID); //if part is not there anymore, then delete it if (changedpart == null) { context.Entry(item).State = EntityState.Deleted; } else { item.Quantity = changedpart.Qty; item.PurchasePrice = changedpart.Price; context.Entry(item).State = EntityState.Modified; } } foreach (var item in order.OrderDetails) { var newpart = !details.Any(x => x.PartID == item.PartID); if (newpart == true) { //check if they added a zero if (item.Qty == 0) { throw new Exception("You cannot add a product into an order with 0 as quantity"); } else { var newitem = new PurchaseOrderDetail { PartID = item.PartID, Quantity = item.Qty, PurchasePrice = item.Price }; updatedOrder.PurchaseOrderDetails.Add(newitem); } //update Quantity on Order after order is placed var updatedPart = context.Parts.Find(item.PartID); updatedPart.QuantityOnOrder = item.Qty; } } context.Entry(updatedOrder).State = EntityState.Modified; context.SaveChanges(); } } }
/// <summary> /// 提交订单,保存修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { this.btnSubmit.Enabled = false; this.dataGridView1.EndEdit(); try { if (this.dataGridView1.Rows.Count <= 0) { MessageBox.Show("您至少需要增加一条采购药品信息,请选择采购药品", "错误", MessageBoxButtons.OK); this.btnSubmit.Enabled = true; return; } foreach (DataGridViewRow dr in this.dataGridView1.Rows) { if (Convert.ToDecimal(dr.Cells[clmDrugNumber.Name].Value) <= 0 || Convert.ToDecimal(dr.Cells[clmPurchasePrice.Name].Value) <= 0) { MessageBox.Show("单价或数量为0"); this.btnSubmit.Enabled = true; dataGridView1.CurrentCell = dr.Cells[clmDrugNumber.Name]; dataGridView1.BeginEdit(true); return; } } string msg = string.Empty; #region 构造主表 PurchaseOrder order = new PurchaseOrder(); List <PurchaseOrderDetail> orderDetails = new List <PurchaseOrderDetail>(); order.Decription = txtDescription.Text; order.SupplyUnitId = _order.SupplyUnitId; order.Id = _order.Id; order.CreateUserId = _order.CreateUserId; order.OrderStatusValue = (int)OrderStatus.Waitting; order.AllReceiptedDate = dtpAllReceiptedDate.Value; order.UpdateUserId = AppClientContext.CurrentUser.Id; #endregion #region 构造明细表 for (int j = 0; j < this._listPurchaseOrderDetail.Count; j++) { PurchaseOrderDetail detail = new PurchaseOrderDetail(); detail.AmountOfTax = this._listPurchaseOrderDetail[j].AmountOfTax; detail.DrugInfoId = this._listPurchaseOrderDetail[j].DrugInfoId; detail.Amount = this._listPurchaseOrderDetail[j].Amount; detail.PurchasePrice = this._listPurchaseOrderDetail[j].PurchasePrice; detail.Id = _listPurchaseOrderDetail[j].Id; detail.sequence = j; detail.Deleted = _listPurchaseOrderDetail[j].isdeleted; orderDetails.Add(detail); } #endregion this.PharmacyDatabaseService.CreatePurchaseOrder(out msg, order, orderDetails.ToArray()); if (!String.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "错误", MessageBoxButtons.OK); return; } PurchaseOrder updateOrder = this.PharmacyDatabaseService.GetPurchaseOrder(out msg, order.Id); nudTotalMoney.Value = updateOrder.TotalMoney; lblOrderStatus.Text = EnumHelper <OrderStatus> .GetDisplayValue(OrderStatus.Waitting);; btnSubmit.Enabled = false; MessageBox.Show("采购记录修改成功", "提示", MessageBoxButtons.OK); this.PharmacyDatabaseService.WriteLog(AppClientContext.CurrentUser.Id, "执行更新采购记录单细节操作成功,采购单号:" + updateOrder.DocumentNumber); this.btnSubmit.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK); this.btnSubmit.Enabled = true; Log.Error(ex); } }
/// <summary> /// Create a new PurchaseOrderDetail object. /// </summary> /// <param name="purchaseOrderID">Initial value of PurchaseOrderID.</param> /// <param name="purchaseOrderDetailID">Initial value of PurchaseOrderDetailID.</param> /// <param name="dueDate">Initial value of DueDate.</param> /// <param name="orderQty">Initial value of OrderQty.</param> /// <param name="unitPrice">Initial value of UnitPrice.</param> /// <param name="lineTotal">Initial value of LineTotal.</param> /// <param name="receivedQty">Initial value of ReceivedQty.</param> /// <param name="rejectedQty">Initial value of RejectedQty.</param> /// <param name="stockedQty">Initial value of StockedQty.</param> /// <param name="modifiedDate">Initial value of ModifiedDate.</param> public static PurchaseOrderDetail CreatePurchaseOrderDetail(int purchaseOrderID, int purchaseOrderDetailID, global::System.DateTime dueDate, short orderQty, decimal unitPrice, decimal lineTotal, decimal receivedQty, decimal rejectedQty, decimal stockedQty, global::System.DateTime modifiedDate) { PurchaseOrderDetail purchaseOrderDetail = new PurchaseOrderDetail(); purchaseOrderDetail.PurchaseOrderID = purchaseOrderID; purchaseOrderDetail.PurchaseOrderDetailID = purchaseOrderDetailID; purchaseOrderDetail.DueDate = dueDate; purchaseOrderDetail.OrderQty = orderQty; purchaseOrderDetail.UnitPrice = unitPrice; purchaseOrderDetail.LineTotal = lineTotal; purchaseOrderDetail.ReceivedQty = receivedQty; purchaseOrderDetail.RejectedQty = rejectedQty; purchaseOrderDetail.StockedQty = stockedQty; purchaseOrderDetail.ModifiedDate = modifiedDate; return purchaseOrderDetail; }
/// <summary> /// Delete Purchase Order Detail /// </summary> /// <param name="purchaseOrderDetailId"></param> /// <returns></returns> public async Task DeletePurchaseOrderDetail(int purchaseOrderDetailId) { PurchaseOrderDetail purchaseOrderDetail = await dbConnection.PurchaseOrderDetails.Where(x => x.PurchaseOrderDetailId == purchaseOrderDetailId).FirstOrDefaultAsync(); dbConnection.PurchaseOrderDetails.Remove(purchaseOrderDetail); }
/// <summary> /// GeneratePo /// </summary> /// <param name="proposePoList">proposePoList(EmpID, EstDate, ItemID, supplier1Qty, supplier2Qty, supplier3Qty)</param> /// <returns></returns> public bool generatePo(List<ProposePo> proposePoList) { bool result = true; //filter the proposePoList by supplier List<ProposePo> supplier1 = proposePoList.Where(x => x.supplier1Qty != 0).ToList(); List<ProposePo> supplier2 = proposePoList.Where(x => x.supplier2Qty != 0).ToList(); List<ProposePo> supplier3 = proposePoList.Where(x => x.supplier3Qty != 0).ToList(); //obtain supplier1 ID string supplier1ID = ctx.Supplier.Where(x => x.Rank == 1).First().SupplierID; //obtain supplier2 ID string supplier2ID = ctx.Supplier.Where(x => x.Rank == 2).First().SupplierID; //obtain supplier3 ID string supplier3ID = ctx.Supplier.Where(x => x.Rank == 3).First().SupplierID; //generate po for supplier 1 if (supplier1.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier1ID; po.EmpID = supplier1.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier1.First().EstDate).Date; po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier1.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x=> x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier1) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier1Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } //generate po for supplier 2 if (supplier2.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier2ID; po.EmpID = supplier2.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier2.First().EstDate); po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier2.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier2) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier2Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } //generate po for supplier 3 if (supplier3.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier3ID; po.EmpID = supplier3.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier3.First().EstDate); po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier3.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier3) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier3Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } try { ctx.SaveChanges(); } catch { result = false; } return result; }
/// <summary> /// This method is used to convert the Purchase quotation to order /// </summary> /// <param name="quotationData"></param> /// <returns></returns> public int ConvertToPurchaseOrder(PurchaseQuotationForm quotationData) { int autoId = 0; PurchaseOrder obj = new PurchaseOrder(); //obj.ID = quotationData.Quotation.ID; obj.Sup_Id = quotationData.Quotation.SupplierID; obj.PO_Date = quotationData.Quotation.QuotationDate; obj.PO_Del_Date = DateTime.Now; obj.PO_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.PO_No = "PO-" + (GetLastOrderNo() + 1); obj.PO_TandC = quotationData.Quotation.TermsAndConditions; obj.PO_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.PO_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.PO_Status = Convert.ToByte(PO_Status.unDeposited); obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.IsDeleted = false; try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { if (entities.PurchaseOrders.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null) { //obj.CreatedBy = quotationData.PQModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.PurchaseOrders.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = quotationData.PQModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { PurchaseOrderDetail PQDetails; if (quotationData.QuotationDetails != null) { foreach (PurchaseQuotationDetailEntity PQDetailEntity in quotationData.QuotationDetails) { PQDetails = new PurchaseOrderDetail(); PQDetails.PO_ID = autoId; PQDetails.PO_No = PQDetailEntity.PQNo; PQDetails.PandS_Code = PQDetailEntity.PandSCode; PQDetails.PandS_Name = PQDetailEntity.PandSName; PQDetails.PO_Amount = PQDetailEntity.PQAmount; PQDetails.PO_Discount = PQDetailEntity.PQDiscount; PQDetails.PO_No = PQDetailEntity.PQNo; PQDetails.PO_Price = Convert.ToDecimal(PQDetailEntity.PQPrice); PQDetails.PO_Qty = PQDetailEntity.PQQty; PQDetails.GST_Code = PQDetailEntity.GSTCode; PQDetails.GST_Rate = PQDetailEntity.GSTRate; if (entities.PurchaseOrderDetails.AsNoTracking().FirstOrDefault(x => x.ID == PQDetailEntity.ID) == null) { entities.PurchaseOrderDetails.Add(PQDetails); entities.SaveChanges(); } else { entities.Entry(PQDetails).State = EntityState.Modified; entities.SaveChanges(); } } } PurchaseQuotation objQ = entities.PurchaseQuotations.Where(e => e.PQ_No == quotationData.Quotation.QuotationNo ).SingleOrDefault(); if (objQ != null) { objQ.PQ_Conv_to_PO = true; objQ.Conv_to_No = obj.PO_No; objQ.ModifiedDate = DateTime.Now; entities.SaveChanges(); } } } return(autoId); } catch (Exception ex) { throw ex; } }
/// <summary>Detaches this instance from the entity specified so it's no longer an associated entity</summary> /// <param name="entity">The related entity to detach from</param> private void Detach_PurchaseOrderDetails(PurchaseOrderDetail entity) { this.SendPropertyChanging("PurchaseOrderDetails"); entity.PurchaseOrderHeader = null; }
public ActionResult Save(List <PurchaseOrderDetailsViewModel> purchaseOrderDetailList) { List <Supplier> supList = new List <Supplier>(); foreach (PurchaseOrderDetailsViewModel pod in purchaseOrderDetailList) { Item item = itemService.FindItemByItemCode(pod.ItemCode); ItemPrice itemPrice = itemPriceService.FindOneByItemAndSequence(item, pod.SupplierPriority); if (!supList.Contains(itemPrice.Supplier)) { supList.Add(itemPrice.Supplier); } } List <PurchaseOrder> poList = purchaseOrderService.CreatePOForEachSupplier(supList); List <string> purchaseOrderIds = new List <string>(); foreach (PurchaseOrder pOrder in poList) { pOrder.CreatedBy = userService.FindUserByEmail(System.Web.HttpContext.Current.User.Identity.GetUserName()); pOrder.PurchaseOrderDetails = new List <PurchaseOrderDetail>(); pOrder.DeliveryOrders = new List <DeliveryOrder>(); purchaseOrderService.Save(pOrder); purchaseOrderIds.Add(pOrder.PurchaseOrderNo); } foreach (PurchaseOrderDetailsViewModel pod in purchaseOrderDetailList) { PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.Item = itemService.FindItemByItemCode(pod.ItemCode); poDetail.ItemCode = pod.ItemCode; poDetail.Quantity = pod.QuantityOrdered; poDetail.Status = statusService.FindStatusByStatusId(11); poDetail.Status.StatusId = 11; //poDetail.UpdatedDateTime = DateTime.Now; // poDetail.UpdatedBy = userService.FindUserByEmail(System.Web.HttpContext.Current.User.Identity.GetUserName()); foreach (PurchaseOrder po in poList) { Item item = itemService.FindItemByItemCode(pod.ItemCode); ItemPrice itemPrice = itemPriceService.FindOneByItemAndSequence(item, pod.SupplierPriority); if (itemPrice.SupplierCode == po.SupplierCode) { poDetail.PurchaseOrder = po; po.PurchaseOrderDetails.Add(poDetail); purchaseOrderService.Save(po); break; } } purchaseOrderService.SavePurchaseOrderDetail(poDetail); } return(new JsonResult { Data = new { purchaseOrders = purchaseOrderIds } }); }
public bool ValidDeleteObject(PurchaseOrderDetail purchaseOrderDetail) { purchaseOrderDetail.Errors.Clear(); VDeleteObject(purchaseOrderDetail); return(isValid(purchaseOrderDetail)); }
/// <summary> /// GeneratePo /// </summary> /// <param name="proposePoList">proposePoList(EmpID, EstDate, ItemID, supplier1Qty, supplier2Qty, supplier3Qty)</param> /// <returns></returns> public bool generatePo(List <ProposePo> proposePoList) { bool result = true; //filter the proposePoList by supplier List <ProposePo> supplier1 = proposePoList.Where(x => x.supplier1Qty != 0).ToList(); List <ProposePo> supplier2 = proposePoList.Where(x => x.supplier2Qty != 0).ToList(); List <ProposePo> supplier3 = proposePoList.Where(x => x.supplier3Qty != 0).ToList(); //obtain supplier1 ID string supplier1ID = ctx.Supplier.Where(x => x.Rank == 1).First().SupplierID; //obtain supplier2 ID string supplier2ID = ctx.Supplier.Where(x => x.Rank == 2).First().SupplierID; //obtain supplier3 ID string supplier3ID = ctx.Supplier.Where(x => x.Rank == 3).First().SupplierID; //generate po for supplier 1 if (supplier1.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier1ID; po.EmpID = supplier1.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier1.First().EstDate).Date; po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier1.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier1) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier1Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } //generate po for supplier 2 if (supplier2.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier2ID; po.EmpID = supplier2.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier2.First().EstDate); po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier2.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier2) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier2Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } //generate po for supplier 3 if (supplier3.FirstOrDefault() != null) { //create and add new po to db PurchaseOrder po = new PurchaseOrder(); po.SupplierID = supplier3ID; po.EmpID = supplier3.First().EmpID; po.Date = DateTime.Now; po.EstDate = Convert.ToDateTime(supplier3.First().EstDate); po.Status = "PENDING"; ctx.PurchaseOrder.Add(po); ctx.SaveChanges(); //obtain the PoID of the newly added Po int empID = supplier3.First().EmpID; var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last(); int poLastID = poLast.PoID; double totalamt = 0; //create and add poDetail to db foreach (ProposePo proposepo in supplier3) { ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault(); PurchaseOrderDetail poDetail = new PurchaseOrderDetail(); poDetail.PoID = poLastID; poDetail.ItemID = proposepo.ItemID; poDetail.Qty = proposepo.supplier3Qty; poDetail.Price = itemprice.Price; ctx.PurchaseOrderDetail.Add(poDetail); totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price; } //Update the po total amount poLast.TotalAmt = totalamt; } try { ctx.SaveChanges(); } catch { result = false; } return(result); }
public bool ValidUnconfirmObject(PurchaseOrderDetail purchaseOrderDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IItemService _itemService) { purchaseOrderDetail.Errors.Clear(); VUnconfirmObject(purchaseOrderDetail, _purchaseReceivalDetailService, _itemService); return(isValid(purchaseOrderDetail)); }
private static List <PurchaseOrder> ERP_MES_Po(Hashtable import) { RFC rfc = new RFC(ConfigurationManager.AppSettings["sapServer"].ToString()); //RFC rfc = new RFC("SAPTest"); var lst = new List <PurchaseOrder>(); //RFC调用函数名 string funcName = "ZWMS_PO"; //传输传给RFC函数的DataSet DataSet ids = new DataSet(); //构建RFC传入表DataTable //返回数据的DataSet框架 DataSet ods = new DataSet(); //构建Export参数DataTable DataTable export = new DataTable(); export.TableName = "Export"; export.Columns.Add(new DataColumn("RTMSG", typeof(string)));//消息文本 ods.Tables.Add(export); //构建RFC传出表DataTable DataTable odt1 = new DataTable(); odt1.TableName = "T_EKKO"; odt1.Columns.Add(new DataColumn("BUKRS", typeof(string))); //公司代码 odt1.Columns.Add(new DataColumn("EBELN", typeof(string))); //采购凭证号 odt1.Columns.Add(new DataColumn("LIFNR", typeof(string))); //供应商或债权人的帐号 odt1.Columns.Add(new DataColumn("ZADRESS", typeof(string))); //地址 odt1.Columns.Add(new DataColumn("SSQSS", typeof(string))); //质检控制码 odt1.Columns.Add(new DataColumn("AEDAT", typeof(string))); //记录的创建日期 odt1.Columns.Add(new DataColumn("LAND1", typeof(string))); //国家代码 odt1.Columns.Add(new DataColumn("ORT01", typeof(string))); //城市 odt1.Columns.Add(new DataColumn("ORT02", typeof(string))); //地区 odt1.Columns.Add(new DataColumn("STRAS", typeof(string))); //住宅号及街道 odt1.Columns.Add(new DataColumn("LANDX", typeof(string))); //国家名称 ods.Tables.Add(odt1); DataTable odt2 = new DataTable(); odt2.TableName = "T_EKPO"; odt2.Columns.Add(new DataColumn("EBELN", typeof(string))); //采购凭证号 odt2.Columns.Add(new DataColumn("EBELP", typeof(string))); //采购凭证的项目编号 odt2.Columns.Add(new DataColumn("MATNR", typeof(string))); //物料号 odt2.Columns.Add(new DataColumn("SSQSS", typeof(string))); //质检控制码 odt2.Columns.Add(new DataColumn("WERKS", typeof(string))); //工厂 odt2.Columns.Add(new DataColumn("LGORT", typeof(string))); //库存地点 odt2.Columns.Add(new DataColumn("MENGE", typeof(string))); //采购订单数量 odt2.Columns.Add(new DataColumn("MEINS", typeof(string))); //采购订单的计量单位 odt2.Columns.Add(new DataColumn("RETPO", typeof(string))); //退货标识 X为退货 odt2.Columns.Add(new DataColumn("PSTYP", typeof(string))); //采购项目类别 odt2.Columns.Add(new DataColumn("INSMK", typeof(string))); //库存类型 odt2.Columns.Add(new DataColumn("WAMNG", typeof(string))); //发货数量 odt2.Columns.Add(new DataColumn("LOEKZ", typeof(string))); //删除标记 odt2.Columns.Add(new DataColumn("ELIKZ", typeof(string))); //交货完成(接收完成) ods.Tables.Add(odt2); //执行RFC函数 bool ret = rfc.DownloadByRFC(funcName, import, ids, ref ods); //根据RFC执行后返回的数据处理业务逻辑 //DataTable dt = ods.Tables["T_ITEM"]; foreach (DataRow h in ods.Tables["T_EKKO"].Rows) { var po = new PurchaseOrder(); string address = h["ZADRESS"].ToString(); po.PoNumber = h["EBELN"].ToString(); po.Supplier = new BD.Suppliers.Supplier { Code = h["LIFNR"].ToString() }; po.CountryCode = h["LAND1"].ToString(); po.CountryName = h["LANDX"].ToString(); po.City = h["ORT01"].ToString(); po.Area = h["ORT02"].ToString(); po.Street = h["STRAS"].ToString(); po.CreateDate = Convert.ToDateTime(h["AEDAT"].ToString()); foreach (DataRow i in ods.Tables["T_EKPO"].AsEnumerable().Where(p => h["EBELN"].ToString() == p["EBELN"].ToString())) { var poDetail = new PurchaseOrderDetail() { IqcFlag = i["SSQSS"].ToString().Trim(), Item = new Item { Code = i["MATNR"].ToString() }, ProjectNo = i["EBELP"].ToString().Trim(), Quantity = Convert.ToDouble(i["MENGE"] ?? 0), Unit = i["MEINS"].ToString(), Factory = i["WERKS"].ToString(), Warehouse = i["LGORT"].ToString(), PurchaseType = (PurchaseType?)Convert.ToInt32(i["PSTYP"]), IsReturn = i["RETPO"].ToString().ToUpper() == "X", ErpReceivedQty = Convert.ToDouble(i["WAMNG"] ?? 0), State = i["ELIKZ"].ToString().ToUpper() == "X" ? PoState.Received : PoState.New, }; po.PurchaseOrderDetailList.Add(poDetail); } lst.Add(po); } return(lst); }
private void CleanReferenceObject(PurchaseOrderDetail entity) { entity.PurchaseOrder = null; entity.Part = null; }
protected void Page_Load(object sender, EventArgs e) { try { Aim.Portal.Web.WebPortalService.CheckLogon(); } catch { Response.Write("<script> window.location.href = '/Login.aspx';</script>"); Response.End(); } string action = Request["action"]; DataTable dt = null; string where = ""; string id = Request["id"]; PurchaseOrder poEnt = null; if (!string.IsNullOrEmpty(id)) { poEnt = PurchaseOrder.Find(id); } IList <PurchaseOrderDetail> podEnts = null; switch (action) { case "load": if (!string.IsNullOrEmpty(Request["PurchaseOrderNo"])) { where += " and PurchaseOrderNo like '%" + Request["PurchaseOrderNo"].Trim() + "%'"; } if (!string.IsNullOrEmpty(Request["SupplierName"])) { where += " and SupplierName like '%" + Request["SupplierName"].Trim() + "%'"; } if (!string.IsNullOrEmpty(Request["InWarehouseState"])) { where += " and InWarehouseState = '" + Request["InWarehouseState"] + "'"; } if (!string.IsNullOrEmpty(Request["ProductCode"])) { where += " and Id in (select distinct PurchaseOrderId from SHHG_AimExamine..PurchaseOrderDetail where Code like '%" + Request["ProductCode"] + "%')"; } sql = @"select *,(select sum(b.RuKuDanQuan) from SHHG_AimExamine..PurchaseOrderDetail b where b.PurchaseOrderId=PurchaseOrder.Id) as RuKuDanQuan, (select sum(b.Quantity) from SHHG_AimExamine..PurchaseOrderDetail b where b.PurchaseOrderId=PurchaseOrder.Id) as DetailQuan from SHHG_AimExamine..PurchaseOrder where GoodsResource='GCPJ' " + where; dt = DataHelper.QueryDataTable(GetPageSql(sql)); Response.Write("{total:" + totalProperty + ",rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "loaddetail": sql = "select * from SHHG_AimExamine..PurchaseOrderDetail where PurchaseOrderId='" + id + "' order by Code asc"; dt = DataHelper.QueryDataTable(sql); Response.Write("{innerrows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "loadsupplier": string supplierName = Request["SupplierName"]; sql = "select * from SHHG_AimExamine..Supplier where SupplierName like '%" + supplierName + "%'"; dt = DataHelper.QueryDataTable(sql); Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "loadproduct": if (!string.IsNullOrEmpty(Request["ProductCode"])) { where += " and Code like '%" + Request["ProductCode"].Trim() + "%'"; } if (!string.IsNullOrEmpty(Request["ProductPcn"])) { where += " and Pcn like '%" + Request["ProductPcn"].Trim() + "%'"; } sql = @"select top 25 a.Id as ProductId,Name,Code,Pcn as PCN,SalePrice as BuyPrice, (select sum(StockQuantity) from SHHG_AimExamine..StockInfo where ProductId=a.Id ) as StockQuantity from SHHG_AimExamine..Products a where ProductType='配件' " + where; dt = DataHelper.QueryDataTable(sql); Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "create": string formdata = Request["formdata"]; string detaildata = Request["detaildata"]; poEnt = JsonHelper.GetObject <PurchaseOrder>(Request["formdata"]); poEnt.CreateId = Aim.Portal.Web.WebPortalService.CurrentUserInfo.UserID; poEnt.CreateName = Aim.Portal.Web.WebPortalService.CurrentUserInfo.Name; poEnt.CreateTime = DateTime.Now; poEnt.GoodsResource = "GCPJ"; poEnt.ProductType = "配件"; poEnt.OrderState = "未结束"; poEnt.PayState = "未付款"; poEnt.InWarehouseState = "未入库"; poEnt.InvoiceState = "未关联"; poEnt.DoCreate(); podEnts = JsonHelper.GetObject <IList <PurchaseOrderDetail> >(Request["detaildata"]); foreach (PurchaseOrderDetail podEnt in podEnts) { podEnt.PurchaseOrderId = poEnt.Id; podEnt.InWarehouseState = "未入库"; podEnt.DoCreate(); } Response.Write("{success:true}"); Response.End(); break; case "loadform": Response.Write("{success:true,data:" + JsonHelper.GetJsonString(poEnt) + "}"); Response.End(); break; case "update": PurchaseOrder newEnt = JsonHelper.GetObject <PurchaseOrder>(Request["formdata"]); EasyDictionary dic = JsonHelper.GetObject <EasyDictionary>(Request["formdata"]); poEnt = DataHelper.MergeData <PurchaseOrder>(poEnt, newEnt, dic.Keys); poEnt.DoUpdate(); sql = "delete from SHHG_AimExamine..PurchaseOrderDetail where PurchaseOrderId='" + id + "'"; DataHelper.ExecSql(sql); podEnts = JsonHelper.GetObject <IList <PurchaseOrderDetail> >(Request["detaildata"]); foreach (PurchaseOrderDetail podEnt in podEnts) { podEnt.PurchaseOrderId = poEnt.Id; podEnt.InWarehouseState = "未入库"; podEnt.DoCreate(); } Response.Write("{success:true}"); Response.End(); break; case "delete": PurchaseOrderDetail.DeleteAll("PurchaseOrderId='" + id + "'"); //删除采购订单详细 poEnt.DoDelete(); Response.Write("{success:true}"); Response.End(); break; } }
/// <summary> /// 从DataTable中获取采购订单明细实体列表 /// </summary> /// <param name="dt"></param> /// <param name="msg"></param> /// <returns></returns> private List <DAL.PurchaseOrderDetail> GetModelDetailFromDataTable(DataTable dt, out string msg) { try { List <DAL.PurchaseOrderDetail> list = new List <DAL.PurchaseOrderDetail>(); msg = ""; //接口协议文档中定义的字段 Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>(); dataFieldNameDic.Add("NCOrderCode", "NC系统订单号"); dataFieldNameDic.Add("DetailRowNumber", "行号"); dataFieldNameDic.Add("ContractNo", "合同号"); dataFieldNameDic.Add("CargoCode", "商品编码"); dataFieldNameDic.Add("CargoName", "商品名称"); dataFieldNameDic.Add("CargoModel", "商品型号"); dataFieldNameDic.Add("CargoSpec", "商品规格"); dataFieldNameDic.Add("WHName", "收货仓库"); dataFieldNameDic.Add("CargoUnits", "商品单位"); dataFieldNameDic.Add("PlanNumber", "应收数量"); dataFieldNameDic.Add("PriceOfTax", "含税单价"); dataFieldNameDic.Add("Price", "单价"); dataFieldNameDic.Add("DeductRate", "折扣"); dataFieldNameDic.Add("PriceOfNetTax", "净含税单价"); dataFieldNameDic.Add("NetPrice", "净单价"); dataFieldNameDic.Add("TotalPrice", "金额"); dataFieldNameDic.Add("TaxRate", "税率"); dataFieldNameDic.Add("TotalTax", "税额"); dataFieldNameDic.Add("TotalTaxAndPrice", "价税合计"); dataFieldNameDic.Add("PlanArrivalDate", "计划到货日期"); dataFieldNameDic.Add("CurrencyType", "币种"); dataFieldNameDic.Add("ExchangeRate", "汇率"); dataFieldNameDic.Add("ReceiveCompany", "收货公司"); dataFieldNameDic.Add("ReceiveOrg", "收货库存组织"); dataFieldNameDic.Add("ReceiveBillCompany", "收票公司"); if (dt == null || dt.Rows.Count == 0) { msg = "用友系统返回数据集中无数据!"; return(new List <PurchaseOrderDetail>()); } StringBuilder errorColName = new StringBuilder(); //检查数据集中是否存在指定字段 foreach (KeyValuePair <string, string> kvp in dataFieldNameDic) { if (dt.Columns.Contains(kvp.Key) == false) { errorColName.Append(Environment.NewLine); errorColName.Append(kvp.Value); errorColName.Append("-"); errorColName.Append(kvp.Key); } } if (errorColName.Length > 0) { errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!"); msg = errorColName.ToString(); return(new List <PurchaseOrderDetail>());; } //遍历数据集创建实体 foreach (DataRow dr in dt.Rows) { PurchaseOrderDetail newModel = new PurchaseOrderDetail(); newModel.NCOrderCode = DataCheckHelper.GetCellString(dr["NCOrderCode"]); newModel.DetailRowNumber = DataCheckHelper.GetCellString(dr["DetailRowNumber"]); newModel.ContractNo = DataCheckHelper.GetCellString(dr["ContractNo"]); //商品编码 newModel.CargoCode = DataCheckHelper.GetCellString(dr["CargoCode"]); string cargoCode = DbCommonMethod.ParsingCargoCode(newModel.CargoCode); if (string.IsNullOrEmpty(cargoCode)) { throw new ApplicationException("单号" + newModel.NCOrderCode + ",商品不存在:" + newModel.CargoCode); } newModel.CargoName = DataCheckHelper.GetCellString(dr["CargoName"]); newModel.CargoModel = DataCheckHelper.GetCellString(dr["CargoModel"]); newModel.CargoSpec = DataCheckHelper.GetCellString(dr["CargoSpec"]); //仓库 newModel.WHName = DataCheckHelper.GetCellString(dr["WHName"]); if (newModel.WHName != "") { newModel.WHCode = DbCommonMethod.ParsingWarehouse(newModel.WHName); if (string.IsNullOrEmpty(newModel.WHCode)) { throw new ApplicationException("单号" + newModel.NCOrderCode + ",仓库不存在:" + newModel.WHName); } } newModel.CargoUnits = DataCheckHelper.GetCellString(dr["CargoUnits"]); //数量 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PlanNumber"]))) { Double number; if (Double.TryParse(DataCheckHelper.GetCellString(dr["PlanNumber"]), out number)) { newModel.NumOriginalPlan = number; } } //含税单价 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PriceOfTax"]))) { decimal priceOfTax; if (decimal.TryParse(DataCheckHelper.GetCellString(dr["PriceOfTax"]), out priceOfTax)) { newModel.PriceOfTax = priceOfTax; } } //单价 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["Price"]))) { decimal price; if (decimal.TryParse(DataCheckHelper.GetCellString(dr["Price"]), out price)) { newModel.Price = price; } } //折扣率 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["DeductRate"]))) { double deductRate; if (double.TryParse(DataCheckHelper.GetCellString(dr["DeductRate"]), out deductRate)) { newModel.DeductRate = deductRate; } } //净含税单价 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PriceOfNetTax"]))) { decimal priceOfNetTax; if (decimal.TryParse(DataCheckHelper.GetCellString(dr["PriceOfNetTax"]), out priceOfNetTax)) { newModel.PriceOfNetTax = priceOfNetTax; } } //净单价 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["NetPrice"]))) { decimal d; if (decimal.TryParse(DataCheckHelper.GetCellString(dr["NetPrice"]), out d)) { newModel.NetPrice = d; } } //金额 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalPrice"]))) { decimal d; if (decimal.TryParse(DataCheckHelper.GetCellString(dr["TotalPrice"]), out d)) { newModel.TotalPrice = d; } } //税率 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TaxRate"]))) { double d; if (double.TryParse(DataCheckHelper.GetCellString(dr["TaxRate"]), out d)) { newModel.TaxRate = d; } } //税额 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalTax"]))) { decimal d; if (decimal.TryParse(DataCheckHelper.GetCellString(dr["TotalTax"]), out d)) { newModel.TotalTax = d; } } //价税合计 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalTaxAndPrice"]))) { decimal d; if (decimal.TryParse(DataCheckHelper.GetCellString(dr["TotalTaxAndPrice"]), out d)) { newModel.TotalTaxAndPrice = d; } } //计划到货日期 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PlanArrivalDate"]))) { DateTime d; if (DateTime.TryParse(DataCheckHelper.GetCellString(dr["PlanArrivalDate"]), out d)) { newModel.PlanArrivalDate = d; } } newModel.CurrencyType = DataCheckHelper.GetCellString(dr["CurrencyType"]); //折本汇率 if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["ExchangeRate"]))) { double d; if (double.TryParse(DataCheckHelper.GetCellString(dr["ExchangeRate"]), out d)) { newModel.ExchangeRate = d; } } newModel.ReceiveCompany = DataCheckHelper.GetCellString(dr["ReceiveCompany"]); newModel.ReceiveOrg = DataCheckHelper.GetCellString(dr["ReceiveOrg"]); newModel.ReceiveBillCompany = DataCheckHelper.GetCellString(dr["ReceiveBillCompany"]); newModel.DetailRowStatus = 2;//初始态 newModel.OrderCode = newModel.OrderCode; newModel.NCOrderCode = newModel.NCOrderCode; List <PurchaseOrderDetail> existPurchaseOrderDetail = (from r in list where r.NCOrderCode == newModel.NCOrderCode && r.DetailRowNumber == newModel.DetailRowNumber select r).ToList <PurchaseOrderDetail>(); if (existPurchaseOrderDetail == null || existPurchaseOrderDetail.Count == 0)//过滤重复数据 { list.Add(newModel); } } return(list); } catch (Exception ex) { msg = ex.Message; return(new List <PurchaseOrderDetail>());; } }
public List <CurrentActiveOrderList> List_StockItemsForSuggestedNewOrder(int vendorid, int employeeid) { using (var context = new eToolsContext()) { //check if vendor already has current open order var exists = context.PurchaseOrders. Where(x => x.VendorID.Equals(vendorid) && x.OrderDate == null).Select(x => x).FirstOrDefault(); if (exists != null) { var results = (from x in context.PurchaseOrderDetails where x.PurchaseOrder.VendorID == exists.VendorID && x.PurchaseOrder.PurchaseOrderNumber == null && x.PurchaseOrder.OrderDate == null orderby x.StockItem.Description select new CurrentActiveOrderList { StockItemID = x.StockItem.StockItemID, Description = x.StockItem.Description, QuantityOnHand = x.StockItem.QuantityOnHand, QuantityOnOrder = x.StockItem.QuantityOnOrder, ReOrderLevel = x.StockItem.ReOrderLevel, QuantityToOrder = x.Quantity, Price = Math.Round(x.StockItem.PurchasePrice, 2) }); return(results.ToList()); } else { var results = (from x in context.StockItems where x.VendorID == vendorid && x.ReOrderLevel > (x.QuantityOnHand + x.QuantityOnOrder) orderby x.Description select new CurrentActiveOrderList { StockItemID = x.StockItemID, Description = x.Description, QuantityOnHand = x.QuantityOnHand, QuantityOnOrder = x.QuantityOnOrder, ReOrderLevel = x.ReOrderLevel, QuantityToOrder = 1, Price = Math.Round(x.PurchasePrice, 2) }); // I must create a new purchase order record List <string> reasons = new List <string>(); decimal sub = 0; PurchaseOrder info = info = new PurchaseOrder(); info.EmployeeID = employeeid; info.VendorID = vendorid; info = context.PurchaseOrders.Add(info); PurchaseOrderDetail neworderdetails = null; foreach (var temp in results.ToList()) { neworderdetails = new PurchaseOrderDetail(); neworderdetails.StockItemID = temp.StockItemID; neworderdetails.PurchasePrice = temp.Price; neworderdetails.Quantity = temp.QuantityToOrder; sub += (temp.Price) * (decimal)(temp.QuantityToOrder); info.PurchaseOrderDetails.Add(neworderdetails); } info.SubTotal = Math.Round(sub, 2); info.TaxAmount = Math.Round((sub * (decimal)0.05), 2); //total = Math.Round(sub, 2) + Math.Round((sub * (decimal)0.05), 2); //} context.SaveChanges(); return(results.ToList()); } } }
void before_each() { var db = new OffsetPrintingSuppliesEntities(); using (db) { db.DeleteAllTables(); _contactService = new ContactService(new ContactRepository(), new ContactValidator()); _itemService = new ItemService(new ItemRepository(), new ItemValidator()); _stockMutationService = new StockMutationService(new StockMutationRepository(), new StockMutationValidator()); _purchaseInvoiceService = new PurchaseInvoiceService(new PurchaseInvoiceRepository(), new PurchaseInvoiceValidator()); _purchaseInvoiceDetailService = new PurchaseInvoiceDetailService(new PurchaseInvoiceDetailRepository(), new PurchaseInvoiceDetailValidator()); _purchaseOrderService = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator()); _purchaseOrderDetailService = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator()); _purchaseReceivalService = new PurchaseReceivalService(new PurchaseReceivalRepository(), new PurchaseReceivalValidator()); _purchaseReceivalDetailService = new PurchaseReceivalDetailService(new PurchaseReceivalDetailRepository(), new PurchaseReceivalDetailValidator()); _stockAdjustmentService = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator()); _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator()); _itemTypeService = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator()); _uomService = new UoMService(new UoMRepository(), new UoMValidator()); _warehouseItemService = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator()); _warehouseService = new WarehouseService(new WarehouseRepository(), new WarehouseValidator()); _barringService = new BarringService(new BarringRepository(), new BarringValidator()); _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator()); _contactGroupService = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator()); _accountService = new AccountService(new AccountRepository(), new AccountValidator()); _generalLedgerJournalService = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator()); _closingService = new ClosingService(new ClosingRepository(), new ClosingValidator()); if (!_accountService.GetLegacyObjects().Any()) { Asset = _accountService.CreateLegacyObject(new Account() { Name = "Asset", Code = Constant.AccountCode.Asset, LegacyCode = Constant.AccountLegacyCode.Asset, Level = 1, Group = Constant.AccountGroup.Asset, IsLegacy = true }, _accountService); CashBank = _accountService.CreateLegacyObject(new Account() { Name = "CashBank", Code = Constant.AccountCode.CashBank, LegacyCode = Constant.AccountLegacyCode.CashBank, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); AccountReceivable = _accountService.CreateLegacyObject(new Account() { Name = "Account Receivable", IsLeaf = true, Code = Constant.AccountCode.AccountReceivable, LegacyCode = Constant.AccountLegacyCode.AccountReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); GBCHReceivable = _accountService.CreateLegacyObject(new Account() { Name = "GBCH Receivable", IsLeaf = true, Code = Constant.AccountCode.GBCHReceivable, LegacyCode = Constant.AccountLegacyCode.GBCHReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); Inventory = _accountService.CreateLegacyObject(new Account() { Name = "Inventory", IsLeaf = true, Code = Constant.AccountCode.Inventory, LegacyCode = Constant.AccountLegacyCode.Inventory, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true }, _accountService); Expense = _accountService.CreateLegacyObject(new Account() { Name = "Expense", Code = Constant.AccountCode.Expense, LegacyCode = Constant.AccountLegacyCode.Expense, Level = 1, Group = Constant.AccountGroup.Expense, IsLegacy = true }, _accountService); CashBankAdjustmentExpense = _accountService.CreateLegacyObject(new Account() { Name = "CashBank Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.CashBankAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.CashBankAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); COGS = _accountService.CreateLegacyObject(new Account() { Name = "Cost Of Goods Sold", IsLeaf = true, Code = Constant.AccountCode.COGS, LegacyCode = Constant.AccountLegacyCode.COGS, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); Discount = _accountService.CreateLegacyObject(new Account() { Name = "Discount", IsLeaf = true, Code = Constant.AccountCode.Discount, LegacyCode = Constant.AccountLegacyCode.Discount, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); SalesAllowance = _accountService.CreateLegacyObject(new Account() { Name = "Sales Allowance", IsLeaf = true, Code = Constant.AccountCode.SalesAllowance, LegacyCode = Constant.AccountLegacyCode.SalesAllowance, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); StockAdjustmentExpense = _accountService.CreateLegacyObject(new Account() { Name = "Stock Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.StockAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.StockAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true }, _accountService); Liability = _accountService.CreateLegacyObject(new Account() { Name = "Liability", Code = Constant.AccountCode.Liability, LegacyCode = Constant.AccountLegacyCode.Liability, Level = 1, Group = Constant.AccountGroup.Liability, IsLegacy = true }, _accountService); AccountPayable = _accountService.CreateLegacyObject(new Account() { Name = "Account Payable", IsLeaf = true, Code = Constant.AccountCode.AccountPayable, LegacyCode = Constant.AccountLegacyCode.AccountPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); GBCHPayable = _accountService.CreateLegacyObject(new Account() { Name = "GBCH Payable", IsLeaf = true, Code = Constant.AccountCode.GBCHPayable, LegacyCode = Constant.AccountLegacyCode.GBCHPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); GoodsPendingClearance = _accountService.CreateLegacyObject(new Account() { Name = "Goods Pending Clearance", IsLeaf = true, Code = Constant.AccountCode.GoodsPendingClearance, LegacyCode = Constant.AccountLegacyCode.GoodsPendingClearance, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true }, _accountService); Equity = _accountService.CreateLegacyObject(new Account() { Name = "Equity", Code = Constant.AccountCode.Equity, LegacyCode = Constant.AccountLegacyCode.Equity, Level = 1, Group = Constant.AccountGroup.Equity, IsLegacy = true }, _accountService); OwnersEquity = _accountService.CreateLegacyObject(new Account() { Name = "Owners Equity", Code = Constant.AccountCode.OwnersEquity, LegacyCode = Constant.AccountLegacyCode.OwnersEquity, Level = 2, Group = Constant.AccountGroup.Equity, ParentId = Equity.Id, IsLegacy = true }, _accountService); EquityAdjustment = _accountService.CreateLegacyObject(new Account() { Name = "Equity Adjustment", IsLeaf = true, Code = Constant.AccountCode.EquityAdjustment, LegacyCode = Constant.AccountLegacyCode.EquityAdjustment, Level = 3, Group = Constant.AccountGroup.Equity, ParentId = OwnersEquity.Id, IsLegacy = true }, _accountService); Revenue = _accountService.CreateLegacyObject(new Account() { Name = "Revenue", IsLeaf = true, Code = Constant.AccountCode.Revenue, LegacyCode = Constant.AccountLegacyCode.Revenue, Level = 1, Group = Constant.AccountGroup.Revenue, IsLegacy = true }, _accountService); } baseGroup = _contactGroupService.CreateObject(Core.Constants.Constant.GroupType.Base, "Base Group", true); Pcs = new UoM() { Name = "Pcs" }; _uomService.CreateObject(Pcs); contact = new Contact() { Name = "President of Indonesia", Address = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat", ContactNo = "021 3863777", PIC = "Mr. President", PICContactNo = "021 3863777", Email = "*****@*****.**" }; contact = _contactService.CreateObject(contact, _contactGroupService); type = _itemTypeService.CreateObject("Item", "Item"); warehouse = new Warehouse() { Name = "Sentral Solusi Data", Description = "Kali Besar Jakarta", Code = "LCL" }; warehouse = _warehouseService.CreateObject(warehouse, _warehouseItemService, _itemService); item_batiktulis = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Batik Tulis", Category = "Item", Sku = "bt123", UoMId = Pcs.Id }; item_batiktulis = _itemService.CreateObject(item_batiktulis, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService); item_busway = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Busway", Category = "Untuk disumbangkan bagi kebutuhan DKI Jakarta", Sku = "DKI002", UoMId = Pcs.Id }; item_busway = _itemService.CreateObject(item_busway, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService); item_botolaqua = new Item() { ItemTypeId = _itemTypeService.GetObjectByName("Item").Id, Name = "Botol Aqua", Category = "Minuman", Sku = "DKI003", UoMId = Pcs.Id }; item_botolaqua = _itemService.CreateObject(item_botolaqua, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService); StockAdjustment sa = new StockAdjustment() { AdjustmentDate = DateTime.Today, WarehouseId = warehouse.Id, Description = "item adjustment" }; _stockAdjustmentService.CreateObject(sa, _warehouseService); StockAdjustmentDetail sadBatikTulis = new StockAdjustmentDetail() { ItemId = item_batiktulis.Id, Quantity = 1000, StockAdjustmentId = sa.Id }; _stockAdjustmentDetailService.CreateObject(sadBatikTulis, _stockAdjustmentService, _itemService, _warehouseItemService); StockAdjustmentDetail sadBusWay = new StockAdjustmentDetail() { ItemId = item_busway.Id, Quantity = 200, StockAdjustmentId = sa.Id }; _stockAdjustmentDetailService.CreateObject(sadBusWay, _stockAdjustmentService, _itemService, _warehouseItemService); StockAdjustmentDetail sadBotolAqua = new StockAdjustmentDetail() { ItemId = item_botolaqua.Id, Quantity = 20000, StockAdjustmentId = sa.Id }; _stockAdjustmentDetailService.CreateObject(sadBotolAqua, _stockAdjustmentService, _itemService, _warehouseItemService); _stockAdjustmentService.ConfirmObject(sa, DateTime.Today, _stockAdjustmentDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService, _generalLedgerJournalService, _accountService, _closingService); purchaseOrder1 = _purchaseOrderService.CreateObject(contact.Id, new DateTime(2014, 07, 09), _contactService); purchaseOrder2 = _purchaseOrderService.CreateObject(contact.Id, new DateTime(2014, 04, 09), _contactService); purchaseOrderDetail_batiktulis_so1 = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_batiktulis.Id, 500, 2000000, _purchaseOrderService, _itemService); purchaseOrderDetail_busway_so1 = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_busway.Id, 91, 800000000, _purchaseOrderService, _itemService); purchaseOrderDetail_botolaqua_so1 = _purchaseOrderDetailService.CreateObject(purchaseOrder1.Id, item_botolaqua.Id, 2000, 5000, _purchaseOrderService, _itemService); purchaseOrderDetail_batiktulis_so2 = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_batiktulis.Id, 40, 2000500, _purchaseOrderService, _itemService); purchaseOrderDetail_busway_so2 = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_busway.Id, 3, 810000000, _purchaseOrderService, _itemService); purchaseOrderDetail_botolaqua_so2 = _purchaseOrderDetailService.CreateObject(purchaseOrder2.Id, item_botolaqua.Id, 340, 5500, _purchaseOrderService, _itemService); purchaseOrder1 = _purchaseOrderService.ConfirmObject(purchaseOrder1, DateTime.Today, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService); purchaseOrder2 = _purchaseOrderService.ConfirmObject(purchaseOrder2, DateTime.Today, _purchaseOrderDetailService, _stockMutationService, _itemService, _barringService, _warehouseItemService); } }
/// <summary> /// Raise new purchase order /// </summary> /// <param name="orderDate"></param> /// <param name="deliveryDate"></param> /// <param name="supplierId"></param> /// <param name="poDetails"></param> /// <returns></returns> public static bool RaisePORequest(DateTime orderDate, DateTime deliveryDate, string supplierId, List <PurchaseOrderViewModel> poDetails) { if (poDetails == null || poDetails.Count == 0) { return(false); } var tempClassList = DbFactory.Instance.context.Suppliers.Select(x => new TempClass() { deliveryDate = deliveryDate, orderDate = orderDate, status = "Open", supplierId = x.supplierId }).ToList(); // go through each given detail foreach (var detail in poDetails) { var d = tempClassList.Where(x => x.supplierId == detail.supplierID).First(); var dt = new PurchaseOrderViewModel() { itemNo = detail.itemNo, quantity = detail.quantity }; if (d.PurchaseOrderDetails == null) { d.PurchaseOrderDetails = new List <PurchaseOrderViewModel>(); } d.PurchaseOrderDetails.Add(dt); } using (var dbContextTransaction = DbFactory.Instance.context.Database.BeginTransaction()) { try { foreach (var tempClass in tempClassList) { // create a po if (tempClass.PurchaseOrderDetails != null && tempClass.PurchaseOrderDetails.Count > 0) { var p = new PurchaseOrder() { supplierId = tempClass.supplierId, orderDate = tempClass.orderDate, deliveryDate = tempClass.deliveryDate, status = tempClass.status }; DbFactory.Instance.context.PurchaseOrders.Add(p); DbFactory.Instance.context.SaveChanges(); foreach (var detail in tempClass.PurchaseOrderDetails) { var dt = new PurchaseOrderDetail() { poId = p.poId, itemNo = detail.itemNo, quantity = detail.quantity }; DbFactory.Instance.context.PurchaseOrderDetails.Add(dt); DbFactory.Instance.context.SaveChanges(); } } } // commit the transaction dbContextTransaction.Commit(); } catch (Exception e) { dbContextTransaction.Rollback(); return(false); } } return(true); }
public StockAndSupplierDTO RetrieveStockMovement(int stationeryId) { List <StockMovementDTO> stockMovement = new List <StockMovementDTO>(); List <StockMovementBalanceDTO> stockMovementBalance = new List <StockMovementBalanceDTO>(); List <SupplierStockRankDTO> supplierStockRank = new List <SupplierStockRankDTO>(); Stationery s = stationeryRepo.FindById(stationeryId); Category c = categoryRepo.FindById(s.CategoryId); List <SupplierTender> st = (List <SupplierTender>)supplierTenderRepo.FindBy(x => x.StationeryId == stationeryId); List <Supplier> sp = new List <Supplier>(); foreach (SupplierTender rankedsupplier in st) { Supplier supplier = (Supplier)supplierRepo.FindById(rankedsupplier.SupplierId); sp.Add(supplier); } //add Suppliers To SupplierStockRankDTO int limit = 3; for (int i = 1; i <= limit; i++) { SupplierStockRankDTO supstockrank = new SupplierStockRankDTO(); { supstockrank.Rank = i; SupplierTender rankingsupplier = (SupplierTender)supplierTenderRepo.FindOneBy(x => x.StationeryId == stationeryId && x.Rank == i); supstockrank.SupplierCode = rankingsupplier.Supplier.Code; supstockrank.SupplierName = rankingsupplier.Supplier.Name; supstockrank.ContactPerson = rankingsupplier.Supplier.ContactName; supstockrank.ContactNumber = rankingsupplier.Supplier.PhoneNo; supstockrank.Price = rankingsupplier.Price; } supplierStockRank.Add(supstockrank); } //retrieve all adjustment voucher Ids that are acknowledged List <int> avId = adjustmentVoucherRepo.getAdjustmentVoucherIdsWithAcknowledgedStatus(); //retrieve all adjustment voucher details with adjustment voucher Ids that are acknowledged and stationeryId List <AdjustmentVoucherDetail> avDet = new List <AdjustmentVoucherDetail>(); foreach (int adjvouch in avId) { List <AdjustmentVoucherDetail> adjvouchDetail = (List <AdjustmentVoucherDetail>)adjustmentVoucherDetailRepo.FindBy(x => x.AdjustmentVoucherId == adjvouch && x.StationeryId == stationeryId); foreach (AdjustmentVoucherDetail aVD in adjvouchDetail) { avDet.Add(aVD); } } // set retrieved adjustmentvouchers into StockMovementDTO foreach (AdjustmentVoucherDetail adjV in avDet) { StockMovementDTO stockMovList = new StockMovementDTO(); { stockMovList.MovementDate = adjV.DateTime; stockMovList.DepartmentOrSupplier = "Adjustment Voucher - " + adjV.AdjustmentVoucherId; stockMovList.Quantity = adjV.Quantity; } stockMovement.Add(stockMovList); } //retrieve all purchase Order Ids that are closed List <int> poId = purchaseOrderRepo.getPurchaseOrderIdsWithClosedStatus(); //retrieve all PO details with PO Ids that are closed and stationeryId List <PurchaseOrderDetail> purchaseOrderDet = new List <PurchaseOrderDetail>(); foreach (int a in poId) { PurchaseOrderDetail purOrderDetail = (PurchaseOrderDetail)purchaseOrderDetailRepo.FindOneBy(x => x.PurchaseOrderId == a && x.StationeryId == stationeryId); purchaseOrderDet.Add(purOrderDetail); } // set retrieved PODetails into StockMovementDTO foreach (PurchaseOrderDetail poDetail in purchaseOrderDet) { if (poDetail != null) { StockMovementDTO stockMovList = new StockMovementDTO(); { stockMovList.MovementDate = (DateTime)purchaseOrderRepo.FindById(poDetail.PurchaseOrderId).DeliveryDateTime; stockMovList.DepartmentOrSupplier = "Supplier - " + supplierRepo.FindById(purchaseOrderRepo.FindById(poDetail.PurchaseOrderId).SupplierId).Name; stockMovList.Quantity = (int)poDetail.QuantityDelivered; } stockMovement.Add(stockMovList); } } //retrieve all requisitiondetails that are delivered and are of the input stationeryId List <RequisitionDetail> reqDet = (List <RequisitionDetail>)requisitionDetailRepo.FindBy(x => x.Status == "Collected" && x.StationeryId == stationeryId); // set retrieved PODetails into StockMovementDTO foreach (RequisitionDetail reqDetails in reqDet) { StockMovementDTO stockMovList = new StockMovementDTO(); stockMovList.MovementDate = (DateTime)reqDetails.Disbursement.DeliveryDateTime; int rcdEmployeeId = (int)disbursementRepo.FindOneBy(x => x.Id == reqDetails.DisbursementId).ReceivedEmployeeId; stockMovList.DepartmentOrSupplier = employeeRepo.FindById(rcdEmployeeId).Department.DepartmentName;; stockMovList.Quantity = (int)reqDetails.QuantityDelivered * -1; stockMovement.Add(stockMovList); } // order the list by date & alphabetically stockMovement = stockMovement.OrderBy(x => x.MovementDate).ToList(); int runningBal = 0; // set StockMovementDTO into StockMovementBalanceDTO foreach (StockMovementDTO stkMovDTO in stockMovement) { StockMovementBalanceDTO stockMovBalList = new StockMovementBalanceDTO(); stockMovBalList.StockMovement = stkMovDTO; runningBal = runningBal + stkMovDTO.Quantity; stockMovBalList.Balance = runningBal; stockMovementBalance.Add(stockMovBalList); } stockMovement.Reverse(); //stockMovementBalance.Reverse(); // set StockMovementBalanceDTO into StockAndSupplierDTO StockAndSupplierDTO stockAndSuppliers = new StockAndSupplierDTO(); stockAndSuppliers.StationeryId = s.Id; stockAndSuppliers.ItemNumber = s.Code; stockAndSuppliers.Category = (String)categoryRepo.getCategoryType(s.CategoryId); stockAndSuppliers.Description = s.Description; stockAndSuppliers.Location = s.Bin; stockAndSuppliers.UnitOfMeasure = s.UnitOfMeasure; stockAndSuppliers.SupplierStockRank = supplierStockRank; foreach (StockMovementBalanceDTO stockMovementBalanceDTO in stockMovementBalance) { stockMovementBalanceDTO.Balance += s.Quantity - stockMovementBalance.Last().Balance; } stockAndSuppliers.StockMovementBalance = stockMovementBalance; return(stockAndSuppliers); }
public string Insert(PurchaseOrderDetail entity) { return(this.repository.Insert(entity)); }
// POST api/awbuildversion public void Post(PurchaseOrderDetail value) { adventureWorks_BC.PurchaseOrderDetailAdd(value); }
public string Update(PurchaseOrderDetail entity) { return(this.repository.Update(entity)); }
/// <summary>Attaches this instance to the entity specified as an associated entity</summary> /// <param name="entity">The related entity to attach to</param> private void Attach_PurchaseOrderDetails(PurchaseOrderDetail entity) { this.SendPropertyChanging("PurchaseOrderDetails"); entity.Product = this; }
public PurchaseOrderDetail VDeleteObject(PurchaseOrderDetail purchaseOrderDetail) { VHasNotBeenConfirmed(purchaseOrderDetail); return(purchaseOrderDetail); }
public void UpdatePurchaseTest() { IPurchaseRepository repo = new PurchaseRepository(); // IUnitOfWork unit = new UnitOfWork(); // IPurchaseRepository repo = new PurchaseRepository(unit); var header = repo.Single(x => x.VendorID == 1699); Assert.IsNotNull(header); header.VendorID = 1700; var details = header.PurchaseOrderDetails.Where(x => x.ProductID == 999).AsQueryable(); Assert.IsNotNull(details); var detail = details.FirstOrDefault(); detail.ProductID= 997; detail.OrderQty = 300; var newdet = new PurchaseOrderDetail(); newdet.DueDate = DateTime.Now.Date; newdet.ModifiedDate = DateTime.Now.Date; newdet.LineTotal = 10; newdet.OrderQty = 10; newdet.ProductID = 999; newdet.PurchaseOrderID = header.PurchaseOrderID; newdet.ReceivedQty = 0; newdet.RejectedQty = 0; newdet.StockedQty = 0; newdet.UnitPrice = 10; header.PurchaseOrderDetails.Add(newdet); header.PurchaseOrderDetails.Add(new PurchaseOrderDetail() { DueDate = DateTime.Now.Date , OrderQty = 25 , ProductID = 998 , UnitPrice = 600 , LineTotal = 700 , ReceivedQty = 25 , RejectedQty = 0 , StockedQty = 0 , ModifiedDate = DateTime.Now.Date }); repo.Attach(header); header = repo.Single(x => x.VendorID == 1700); Assert.IsNotNull(header); details = header.PurchaseOrderDetails.Where(x => x.ProductID == 997).AsQueryable(); Assert.IsNotNull(details); //var pocoDept = Mapper.Map<Department, dDepartment>(department); //return pocoDept; }
public bool ValidCreateObject(PurchaseOrderDetail purchaseOrderDetail, IPurchaseOrderDetailService _purchaseOrderDetails, IPurchaseOrderService _purchaseOrderService, IItemService _itemService) { VCreateObject(purchaseOrderDetail, _purchaseOrderDetails, _purchaseOrderService, _itemService); return(isValid(purchaseOrderDetail)); }
public void AddToPurchaseOrderDetails(PurchaseOrderDetail purchaseOrderDetail) { base.AddObject("PurchaseOrderDetails", purchaseOrderDetail); }
public bool ValidUpdateObject(PurchaseOrderDetail purchaseOrderDetail, IPurchaseOrderDetailService _purchaseOrderDetails, IPurchaseOrderService _purchaseOrderService, IItemService _itemService) { purchaseOrderDetail.Errors.Clear(); VUpdateObject(purchaseOrderDetail, _purchaseOrderDetails, _purchaseOrderService, _itemService); return(isValid(purchaseOrderDetail)); }
partial void PurchaseOrderDetails_Updating(PurchaseOrderDetail entity) { //if (entity.ReceiveDate != null) //{ // string receiveType = getPOTransactionType(entity.Product); // entity.LotNo = getNewLotFromStockOnhand(receiveType, entity.ReceiveDate.Value, entity.Product, ""); //} }
public static PurchaseOrderDetail CreatePurchaseOrderDetail(int ID, int purchaseOrderDetails_PurchaseOrder, int purchaseOrderDetails_Product, int unitsOrdered, decimal discount, decimal unitPricePaid, byte[] rowVersion) { PurchaseOrderDetail purchaseOrderDetail = new PurchaseOrderDetail(); purchaseOrderDetail.Id = ID; purchaseOrderDetail.PurchaseOrderDetails_PurchaseOrder = purchaseOrderDetails_PurchaseOrder; purchaseOrderDetail.PurchaseOrderDetails_Product = purchaseOrderDetails_Product; purchaseOrderDetail.UnitsOrdered = unitsOrdered; purchaseOrderDetail.Discount = discount; purchaseOrderDetail.UnitPricePaid = unitPricePaid; purchaseOrderDetail.RowVersion = rowVersion; return purchaseOrderDetail; }