public static OrderDetail GenerateOrderDetail(int unitId, int activityId, decimal pack, int orderId, int qtyPerPack, int itemId) { var ord = new OrderDetail(); ord.LoadByItemUnit(orderId, itemId, unitId, activityId); if (ord.RowCount == 0) { ord.AddNew(); ord.OrderID = orderId; ord.ItemID = itemId; ord.UnitID = unitId; ord.StoreID = activityId; ord.Pack = pack; ord.QtyPerPack = qtyPerPack; ord.Quantity = pack * qtyPerPack; ord.ApprovedQuantity = pack * qtyPerPack; } else { ord.Pack += pack; ord.Quantity += pack; ord.ApprovedQuantity += pack * qtyPerPack; } ord.Save(); return(ord); }
public int Split() { OrderDetail ordDetail = new OrderDetail(); ordDetail.AddNew(); foreach (DataRow dr in this.DataTable.Rows) { foreach (DataColumn col in ordDetail.DataTable.Columns) { if (col.ColumnName != "ID" && col.ColumnName != "JTransactionGroupID" && col.ColumnName != "cMin" && col.ColumnName != "cAMC" && col.ColumnName != "cDaysOutofStock" && col.ColumnName != "cDamagedStock" && col.ColumnName != "cMin" && col.ColumnName != "cExpiredStock" && col.ColumnName != "cStockOnHand" && col.ColumnName != "cMOS" && col.ColumnName != "cMax" && col.ColumnName != "rowguid") { ordDetail.SetColumn(col.ColumnName, this.GetColumn(col.ColumnName)); } } } ordDetail.Save(); return(ordDetail.ID); }
private void SaveOrder() { var order = GenerateOrder(); var picklist = PickList.GeneratePickList(order.ID); int lineNo = 0; // This is a kind of initializing the data table. OrderDetail ord = new OrderDetail(); PickListDetail pkDetail = new PickListDetail(); DataView dv = orderGrid.DataSource as DataView; foreach (DataRowView r in dv) { if (r["ApprovedPacks"] != null && r["ApprovedPacks"] != DBNull.Value && r["ApprovedPacks"].ToString()!= "") if (Convert.ToInt32(r["ApprovedPacks"]) != 0) { lineNo = lineNo + 1; int itemID = Convert.ToInt32(r["ItemID"]); int unitID = Convert.ToInt32(r["UnitID"]); ord.AddNew(); ord.OrderID = order.ID; ord.ItemID = itemID; if (r["ApprovedPacks"] != DBNull.Value) { ord.Pack = Convert.ToInt32(r["ApprovedPacks"]); } if (r["QtyPerPack"] != DBNull.Value) { ord.QtyPerPack = Convert.ToInt32(r["QtyPerPack"]); } ord.Quantity = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]); ord.ApprovedQuantity = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]); ord.UnitID = unitID; ord.StoreID = Convert.ToInt32(lkAccountType.EditValue); ord.Save(); pkDetail.AddNew(); pkDetail.PickListID = picklist.ID; pkDetail.ItemID = itemID; pkDetail.PalletLocationID = Convert.ToInt32(r["LocationID"]); pkDetail.BatchNumber = r["BatchNo"].ToString(); if (r["ExpDate"] != DBNull.Value) pkDetail.ExpireDate = DateTime.Parse(r["ExpDate"].ToString()); pkDetail.StoreID = Convert.ToInt32(r["StoreID"]); pkDetail.UnitID = unitID; pkDetail.ReceiveDocID = Convert.ToInt32(r["ReceiveDocID"]); if (r["UnitPrice"] != DBNull.Value) { pkDetail.Cost = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]); pkDetail.UnitPrice = Convert.ToDouble(r["UnitPrice"]); } pkDetail.Packs = Convert.ToInt32(r["ApprovedPacks"]); pkDetail.QtyPerPack = Convert.ToInt32(r["QtyPerPack"]); pkDetail.QuantityInBU = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]); pkDetail.StoreID = Convert.ToInt32(r["StoreID"]); pkDetail.ReceivePalletID = Convert.ToInt32(r["ReceivingLocationID"]); pkDetail.ManufacturerID = Convert.ToInt32(r["ManufacturerID"]); pkDetail.BoxLevel = 0; pkDetail.DeliveryNote = true; pkDetail.Save(); //To Print The Picklist //Then reserve Items ReceivePallet receivepallet = new ReceivePallet(); receivepallet.LoadByPrimaryKey(Convert.ToInt32(r["ReceivingLocationID"])); receivepallet.ReservedStock = receivepallet.ReservedStock + Convert.ToInt32(r["ApprovedPacks"]); receivepallet.Save(); DataRow drvpl = dvPickList.NewRow(); drvpl["FullItemName"] = r["FullItemName"]; drvpl["StockCode"] = r["StockCode"]; drvpl["BatchNo"] = r["BatchNo"]; if (r["ExpDate"] != DBNull.Value) drvpl["ExpDate"] = Convert.ToDateTime(r["ExpDate"]).ToString("MMM/yyyy"); else drvpl["ExpDate"] = DBNull.Value; drvpl["LineNum"] = lineNo + 1; drvpl["ManufacturerName"] = r["Manufacturer"]; drvpl["Pack"] = r["ApprovedPacks"]; drvpl["UnitPrice"] = r["UnitPrice"]; drvpl["Unit"] = r["Unit"]; drvpl["PalletLocation"] = r["Location"]; drvpl["QtyInSKU"] = Convert.ToInt32(r["ApprovedPacks"]); if (r["UnitPrice"] != DBNull.Value) drvpl["CalculatedCost"] = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]); PalletLocation palletLocation = new PalletLocation(); palletLocation.LoadByPrimaryKey(pkDetail.PalletLocationID); drvpl["WarehouseName"] = palletLocation.WarehouseName; drvpl["PhysicalStoreName"] = palletLocation.PhysicalStoreName; var activity = new Activity(); activity.LoadByPrimaryKey(pkDetail.StoreID); drvpl["ActivityConcat"] = activity.FullActivityName; drvpl["AccountName"] = activity.AccountName; dvPickList.Rows.Add(drvpl); } } if (lineNo == 0) throw new System.ArgumentException("Please review your list,you haven't approved any Quantity"); var plr = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(order, lkForHub.Text, dvPickList.DefaultView); plr.PrintDialog(); if (!BLL.Settings.IsCenter) { if (TransferTypeID == 3) { XtraMessageBox.Show("Your Store To Store Transfer will be Printed now", "Store To Store Transfer"); Transfer.Move(picklist.ID); HCMIS.Desktop.Reports.StoreTransferPrintOut STM = new HCMIS.Desktop.Reports.StoreTransferPrintOut(); STM.LoadByPickListID(picklist.ID); STM.PrintDialog(); } else if (TransferTypeID == 2) { XtraMessageBox.Show(ReceiveDoc.ReceiveFromAccountTransfer(picklist.ID, Convert.ToInt32(lkForHub.EditValue), CurrentContext.LoggedInUserName, CurrentContext.UserId)); } } else { XtraMessageBox.Show("Picklist Prepared!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Save(Domain.Request _request,int userID, Domain.OrderStatus orderStatus = Domain.OrderStatus.Submitted) { var order = new Order(); order.LoadByPrimaryKey(_request.RequestID); var dborderStatus = new BLL.OrderStatus(); dborderStatus.LoadByCode(EnumService<Domain.OrderStatus>.GetCode(orderStatus)); order.ChangeStatus(dborderStatus.ID,CurrentContext.UserId); order.ApprovedBy = userID; order.ApprovedDate = DateTimeHelper.ServerDateTime; var orderDetail = new OrderDetail(); orderDetail.LoadAllByOrderID(_request.RequestID); while (!orderDetail.EOF) { var requestDetail = _request.RequestDetails.SingleOrDefault(r => r.RequestDetailId == orderDetail.ID); if(requestDetail== null) { orderDetail.MarkAsDeleted(); } else { //Set Activity if (requestDetail.ActivityGroup != null) { orderDetail.StoreID = requestDetail.ActivityGroup.Activity.ActivityID; orderDetail.DeliveryNote = requestDetail.ActivityGroup.IsDeliveryNote; } else { orderDetail.SetColumnNull("StoreID"); } //Set Manufacturer if (requestDetail.Manufacturer != null) { orderDetail.PreferredManufacturerID = requestDetail.Manufacturer.ManufacturerID; } else { orderDetail.SetColumnNull("PreferredManufacturerID"); } //Set PhysicalStore if (requestDetail.physicalStore != null) { orderDetail.PreferredPhysicalStoreID = requestDetail.physicalStore.PhysicalStoreID; } else { orderDetail.SetColumnNull("PreferredPhysicalStoreID"); } //Set ExpiryDate if (requestDetail.ExpiryDate.HasValue) { orderDetail.PreferredExpiryDate = requestDetail.ExpiryDate.Value; } else { orderDetail.SetColumnNull("PreferredExpiryDate"); } orderDetail.ApprovedQuantity = requestDetail.ApprovedQuantity; orderDetail.StockedOut = requestDetail.StockedOut; } orderDetail.MoveNext(); } foreach (var requestDetail in _request.RequestDetails.Where(r => r.RequestDetailId == 0).ToList()) { orderDetail.AddNew(); orderDetail.ItemID = requestDetail.Item.ItemID; orderDetail.UnitID = requestDetail.Unit.UnitID; orderDetail.Pack = requestDetail.RequestedQuantity; orderDetail.OrderID = order.ID; orderDetail.QtyPerPack = 1; orderDetail.Quantity = requestDetail.RequestedQuantity; orderDetail.ApprovedQuantity = requestDetail.ApprovedQuantity; orderDetail.StockedOut = requestDetail.StockedOut; if (requestDetail.ActivityGroup != null) { orderDetail.StoreID = requestDetail.ActivityGroup.Activity.ActivityID; orderDetail.DeliveryNote = requestDetail.ActivityGroup.IsDeliveryNote; } else { orderDetail.SetColumnNull("StoreID"); } //Set Manufacturer if (requestDetail.Manufacturer != null) { orderDetail.PreferredManufacturerID = requestDetail.Manufacturer.ManufacturerID; } else { orderDetail.SetColumnNull("PreferredManufacturerID"); } //Set PhysicalStore if (requestDetail.physicalStore != null) { orderDetail.PreferredPhysicalStoreID = requestDetail.physicalStore.PhysicalStoreID; } else { orderDetail.SetColumnNull("PreferredPhysicalStoreID"); } //Set ExpiryDate if (requestDetail.ExpiryDate.HasValue) { orderDetail.PreferredExpiryDate = requestDetail.ExpiryDate.Value; } else { orderDetail.SetColumnNull("PreferredExpiryDate"); } } order.Save(); orderDetail.Save(); }