private void LoadNewSellingPriceAndAverageCost() { ReceiveDocDetails = ReceiveDoc.GetRelatedReceiveForFinalPriceSetting(ReceiptID, ItemID, ManufacturerID, ItemUnitID, AccountID); //Load Header Information From first row to be displayed if (ReceiveDocDetails.Rows.Count > 0) { DataRow dr = ReceiveDocDetails.Rows[0]; StockCode = ItemName = dr["FullItemName"].ToString(); ItemUnit = dr["ItemUnitName"].ToString(); ManufacturerName = dr["ManufacturerName"].ToString(); ActivityName = dr["ActivityName"].ToString(); if (dr["NewAverageCost"] != DBNull.Value) { NewUnitCost = Math.Round(Convert.ToDouble(dr["NewAverageCost"]), BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } if (dr["NewSellingPrice"] != DBNull.Value) { this.NewSellingPrice = Math.Round(Convert.ToDouble(dr["NewSellingPrice"]), BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } if (dr["Margin"] != DBNull.Value) { this.Margin = Math.Round(Convert.ToDouble(dr["Margin"]), BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } } }
public static bool checkOutstandingReceives(int warehouseID) { var query = HCMIS.Repository.Queries.ReceiveDoc.SelectCheckOutstandingReceives(warehouseID, ReceiptConfirmationStatus.Constants.GRV_PRINTED, ReceiptType.CONSTANTS.STOCK_RETURN, ReceiptType.CONSTANTS.STANDARD_RECEIPT); ReceiveDoc receipt = new ReceiveDoc(); receipt.LoadFromRawSql(query); return receipt.Getint("count") == 0; }
internal void SetStatusConfirmQuantityAndLocation(int receiveID, int? userID) { LoadByReceiveDocID(receiveID); BLL.ReceiveDoc rcDoc=new ReceiveDoc(); BLL.Receipt rct = new Receipt(); rcDoc.LoadByPrimaryKey(receiveID); rct.LoadByPrimaryKey(rcDoc.ReceiptID); if (RowCount == 0) { AddNew(); ReceiveDocID = receiveID; } if(userID.HasValue) { ReceiptQuantityConfirmedByUserID = userID.Value; } ReceiptConfirmationStatusID = rct.ReceiptTypeID == BLL.ReceiptType.CONSTANTS.BEGINNING_BALANCE? ReceiptConfirmationStatus.Constants.GRV_PRINTED: ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED; Save(); }
/// <summary> /// Calculates the current volume of a pallet, /// this assumes that the box levels have all the dimentions set. /// </summary> /// <param name="id"></param> /// <returns></returns> public double CalculateCurrentVolume( int id) { Pallet p = new Pallet(); p.GetAllItemsInPallet(id); ReceiveDoc rd = new ReceiveDoc(); ItemManufacturer im = new ItemManufacturer(); double volume = 0; foreach (DataRowView drv in p.DefaultView) { //Get the recieving box size and manufacturer rd.LoadByPrimaryKey(Convert.ToInt32(drv["ReceiveID"])); //Handle if the box size was not specified for some reason. // this shouldn't happen on a non error condition if (drv["BoxSize"].ToString() == "") { drv["BoxSize"] = 0; } im.LoadIMbyLevel(rd.ItemID, rd.ManufacturerId, Convert.ToInt32(drv["BoxSize"])); if (im.RowCount == 0) { im.LoadIMbyLevel(rd.ItemID, rd.ManufacturerId, 0); } double quantity = Convert.ToInt32(drv["Balance"])/im.QuantityInBasicUnit; volume += quantity * im.Volume; // find the volume of the items in the current pallet. } return volume; }
/// <summary> /// Calculates the current volume of a pallet, /// this assumes that the box levels have all the dimentions set. /// </summary> /// <param name="id"></param> /// <returns></returns> public double CalculateCurrentVolume(int id) { Pallet p = new Pallet(); p.GetAllItemsInPallet(id); ReceiveDoc rd = new ReceiveDoc(); ItemManufacturer im = new ItemManufacturer(); double volume = 0; foreach (DataRowView drv in p.DefaultView) { //Get the recieving box size and manufacturer rd.LoadByPrimaryKey(Convert.ToInt32(drv["ReceiveID"])); //Handle if the box size was not specified for some reason. // this shouldn't happen on a non error condition if (drv["BoxSize"].ToString() == "") { drv["BoxSize"] = 0; } im.LoadIMbyLevel(rd.ItemID, rd.ManufacturerId, Convert.ToInt32(drv["BoxSize"])); if (im.RowCount == 0) { im.LoadIMbyLevel(rd.ItemID, rd.ManufacturerId, 0); } double quantity = Convert.ToInt32(drv["Balance"]) / im.QuantityInBasicUnit; volume += quantity * im.Volume; // find the volume of the items in the current pallet. } return(volume); }
private void gridOrderListView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { DataRow dr = gridOrderListView.GetFocusedDataRow(); if (dr != null) { int receiptID = Convert.ToInt32(dr["ID"]); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadAllByReceiptID(receiptID); DataTable tbl = receiveDoc.DefaultView.ToTable(); ReceiveDocDeleted receiveDocDeleted = new ReceiveDocDeleted(); receiveDocDeleted.LoadAllByReceiptID(receiptID); LogReceiptStatus logReceiptStatus = new LogReceiptStatus(); gridHistory.DataSource = logReceiptStatus.GetLogHistory(receiptID); if (receiveDocDeleted.RowCount > 0) { tbl.Merge(receiveDocDeleted.DefaultView.ToTable()); BLL.User user = new User(); user.LoadByPrimaryKey(receiveDocDeleted.DeletedBy); if (user.RowCount > 0) { lblDeletedBy.Text = string.Format("Deleted By {0}", string.IsNullOrEmpty(user.FullName) ? user.UserName : user.FullName); } } gridOrderDetail.DataSource = tbl; } }
/// <summary> /// Gets the last issued date for the facility /// </summary> /// <param name="storeId"></param> /// <param name="itemId"></param> /// <returns></returns> public static DateTime GetLastReceivedDate() { var rd = new ReceiveDoc(); rd.LoadFromRawSql(String.Format("SELECT TOP (1) EurDate FROM ReceiveDoc ORDER BY EurDate DESC")); DateTime dt = (rd.DataTable.Rows.Count > 0) ? Convert.ToDateTime(rd.DataTable.Rows[0]["EurDate"]) : new DateTime(); return dt; }
private void btnReturn_Click(object sender, EventArgs e) { //TODO: finish updating the changed locations MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); if (gridGRVs.DataSource == null) return; transaction.BeginTransaction(); try { PalletLocation pl = new PalletLocation(); BLL.ReceiveDoc recDoc = new ReceiveDoc(); recDoc.LoadByReceiptID(ReceiptID); recDoc.ConfirmGRNFPrinted(null); BLL.Receipt receiptStatus = new BLL.Receipt(); receiptStatus.LoadByPrimaryKey(ReceiptID); receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRNF_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "Return For Price Change"); transaction.CommitTransaction(); this.LogActivity("Return-For-Costing", ReceiptID); XtraMessageBox.Show("Receipt Returned!", "Success", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } catch (Exception exp) { transaction.RollbackTransaction(); throw exp; } PutAwayListsLoad(null, null); }
/// <summary> /// Deletes the A receive doc entry. /// </summary> /// <param name="receiveDocID">The receive doc ID.</param> /// <param name="userID">The user ID.</param> /// <exception cref="System.Exception"></exception> public static void DeleteAReceiveDocEntry(int receiveDocID, int userID) { var rd = new ReceiveDoc(); rd.LoadByPrimaryKey(receiveDocID); if (rd.RowCount > 0) { if (rd.HasTransactions()) { string printedIDs = ""; var issueDoc = new IssueDoc(); issueDoc.LoadByReceiveDocID(rd.ID); issueDoc.Rewind(); while (!issueDoc.EOF) { var stvs = new BLL.Issue(); stvs.LoadByPrimaryKey(issueDoc.STVID); printedIDs += stvs.IDPrinted.ToString(CultureInfo.InvariantCulture) + " ,"; issueDoc.MoveNext(); } printedIDs = printedIDs.Remove(printedIDs.Length - 1, 1); throw new Exception( string.Format("Please cancel/void the following Stvs: With PrintedIDs : {0}", printedIDs)); } HandleReceiveDocDeleting(receiveDocID, userID, rd); } }
internal static PickListDetail GeneratePickListDetail(ReceivePallet receivePallet, int pickListId, decimal qtyInBU) { ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(receivePallet.ReceiveID); decimal pack = qtyInBU / Convert.ToDecimal(receiveDoc.QtyPerPack); PickListDetail pkDetail = new PickListDetail(); pkDetail.AddNew(); pkDetail.PickListID = pickListId; pkDetail.ItemID = receiveDoc.ItemID; PalletLocation palletLocation = new PalletLocation(); palletLocation.loadByPalletID(receivePallet.PalletID); int palletLocationId; try { palletLocationId = palletLocation.ID; } catch (Exception exp) { palletLocationId = receivePallet.PalletLocationID; palletLocation.LoadByPrimaryKey(palletLocationId); } pkDetail.PalletLocationID = palletLocationId; if (!receiveDoc.IsColumnNull("BatchNo")) { pkDetail.BatchNumber = receiveDoc.BatchNo; } if (!receiveDoc.IsColumnNull("ExpDate")) { pkDetail.ExpireDate = receiveDoc.ExpDate; } pkDetail.StoreID = receiveDoc.StoreID; pkDetail.UnitID = receiveDoc.UnitID; pkDetail.ReceiveDocID = receiveDoc.ID; if (!receiveDoc.IsColumnNull("Cost")) { pkDetail.Cost = Convert.ToDouble(pack) * Math.Round(receiveDoc.Cost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); pkDetail.UnitPrice = Math.Round(receiveDoc.Cost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } pkDetail.Packs = pack; pkDetail.QtyPerPack = receiveDoc.QtyPerPack; pkDetail.QuantityInBU = qtyInBU; pkDetail.StoreID = receiveDoc.StoreID; pkDetail.ReceivePalletID = receivePallet.ID; pkDetail.ManufacturerID = receiveDoc.ManufacturerId; pkDetail.BoxLevel = 0; pkDetail.DeliveryNote = true; pkDetail.PhysicalStoreID = palletLocation.PhysicalStoreID; pkDetail.Save(); return(pkDetail); }
public Int64 GetBBalanceByUnit(int year, int storeId, int itemId, int month, int unitId) { //CALENDAR: this.FlushData(); Int64 bb = 0; //int bYear = ((month > 10) ? year : year - 1); EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(year, month, 30); int bYear = ethioDate.FiscalYear; string query = String.Format( "Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2} and UnitID={3} and (AutomaticallyEntered = 0 or AutomaticallyEntered is null) order by PhysicalInventory desc", storeId, itemId, bYear, unitId); this.LoadFromRawSql(query); if (this.DataTable.Rows.Count > 0 && this.DataTable.Rows[0]["PhysicalInventory"] != DBNull.Value) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else { this.LoadFromRawSql( String.Format( "Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2} and UnitID={3} and (AutomaticallyEntered = 0 or AutomaticallyEntered is null)", storeId, itemId, year - 1, unitId)); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else if (((year + 8) > DateTime.Now.Year) || (month > 10 && (year + 8) == DateTime.Now.Year)) // to check if it is different year from current { Int64 cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); if ((year + 8) > DateTime.Now.Year) // to check if it is hamle and Nehase { year = year - 1; } month = 10; //} long RecievedQuantity = rec.GetReceivedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long AdjustedQuantity = dis.GetAdjustedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long IssuedQuantity = iss.GetIssuedQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); long LossQuantity = dis.GetLossesQuantityTillMonthByUnit(itemId, storeId, month, year, unitId); // long BalanceQuantity = yEnd.GetBBalance(year, storeId, itemId, month); cons = (RecievedQuantity + AdjustedQuantity - IssuedQuantity - LossQuantity); //cons = (rec.GetReceivedQuantityTillMonth(itemId, storeId, month, year) + dis.GetAdjustedQuantityTillMonth(itemId, storeId, month, year) - iss.GetIssuedQuantityTillMonth(itemId, storeId, month, year) - dis.GetLossesQuantityTillMonth(itemId, storeId, month, year)); bb = cons; } } return(bb); }
public void ReleaseForIssue() { foreach (DataRowView drv in GRVSoundDetail.DefaultView) { ReceiveDoc rd = new ReceiveDoc(); rd.releaseForIssue(Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["MovingAverageID"])); } }
public void SuspendFromIssuing() { foreach (DataRowView drv in GRVSoundDetail.DefaultView) { ReceiveDoc rd = new ReceiveDoc(); rd.suspendForPricing(Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["MovingAverageID"])); } }
/// <summary> /// Gets the last issued date for the facility /// </summary> /// <param name="storeId"></param> /// <param name="itemId"></param> /// <returns></returns> public static DateTime GetLastReceivedDate() { var rd = new ReceiveDoc(); rd.LoadFromRawSql(String.Format("SELECT TOP (1) EurDate FROM ReceiveDoc ORDER BY EurDate DESC")); DateTime dt = (rd.DataTable.Rows.Count > 0) ? Convert.ToDateTime(rd.DataTable.Rows[0]["EurDate"]) : new DateTime(); return(dt); }
public void Confirm(int UserId) { foreach (DataRowView Cursor in PreviousStock.DefaultView) { int ID = Convert.ToInt32(Cursor["ID"]); ReceiveDoc.SetAverageCostByReceiveDoc(ID, NewUnitCost, UserId); ReceiveDoc.SetMarginByReceiveDoc(ID, Margin * 100, UserId); ReceiveDoc.SetSellingPriceByReceiveDoc(ID, NewSellingPrice, UserId); } }
private void cboSuppliers_SelectedValueChanged(object sender, EventArgs e) { if (cboSuppliers.EditValue != null) { ReceiveDoc rec = new ReceiveDoc(); DataTable dtRec = new DataTable(); dtRec = rec.GetTransactionBySupplierId(Convert.ToInt32(cboStores.EditValue), Convert.ToInt32(cboSuppliers.EditValue)); PopulateTransactions(dtRec); } }
public void GenerateAutomaticInventoryByUnit() { var ethDate = new EthiopianDate.EthiopianDate(); var stores = new Stores(); stores.GetActiveStores(); var rec = new ReceiveDoc(); var itm = new Items(); var yearEnd = new YearEnd(); var balance = new Balance(); if (!InventoryRequiredForHandlingUnit(false)) { return; } while (!stores.EOF) //This needs to be done for each store and for each item { //bereket //itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnit(stores.ID); itm.ExcludeNeverReceivedItemsNoCategoryForHandlingUnitOptimized(stores.ID, ethDate.Year); while (!itm.EOF) //For each item { var receivedoc = rec.GetDistinctUnitIDFromReceivedDoc(itm.ID); foreach (var dr in receivedoc.Rows.Cast <DataRow>().Where(dr => !DoesBalanceExistByUnit(ethDate.Year, itm.ID, stores.ID, true, Convert.ToInt32(dr["UnitID"])))) { //need optimization //we can exclude the already calculated items when we exclude never recieved items yearEnd.LoadByItemIDStoreAndYearAndUnit(itm.ID, stores.ID, ethDate.Year, true, Convert.ToInt32(dr["UnitID"])); if (yearEnd.RowCount > 0) { continue; } yearEnd.AddNew(); yearEnd.ItemID = itm.ID; yearEnd.StoreID = stores.ID; yearEnd.Year = ethDate.Year; //need optimization //atleast we can get the value directly by filtering using storeid and itemid rather than //selecting all items in all stores and filter it by code //yearEnd.EBalance = balance.GetSOHByUnit(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"])); yearEnd.EBalance = balance.GetSOHByUnitOptimized(itm.ID, stores.ID, ethDate.Month, ethDate.Year, Convert.ToInt32(dr["UnitID"])); yearEnd.PhysicalInventory = yearEnd.EBalance; yearEnd.AutomaticallyEntered = true; yearEnd.UnitID = Convert.ToInt32(dr["UnitID"]); yearEnd.Save(); } itm.MoveNext(); } stores.MoveNext(); } }
internal static int ItemReceived(int itemID, int storeId) { string query = string.Format("select sum(Quantity) as Quantity from ReceiveDoc rd where ItemID = {0} and StoreID = {1}", itemID, storeId); ReceiveDoc rd = new ReceiveDoc(); rd.LoadFromRawSql(query); if (rd.RowCount > 0 && !rd.IsColumnNull("Quantity") && rd.Quantity > 0) { return(1); } return(0); }
/// <summary> /// Load All Neccessary Data and Bind To DataSource /// </summary> void LoadAndBind() { //Bind if (ReceiptID == null) { return; } LoadNewSellingPriceAndAverageCost(); //Load Detail Table To Grid PreviousStock = ReceiveDoc.GetRelatedPreviousStockForUnitCostAndSellingPrice((int)ReceiptID, ItemID, ManufacturerID, ItemUnitID, AccountID, NewUnitCost, NewSellingPrice); Picklist = ReceiveDoc.GetRelatedPicklistForChangingPrice(ItemID, ManufacturerID, ItemUnitID, AccountID, NewSellingPrice); DeliveryNote = ReceiveDoc.GetRelatedDeliveryNotesChangingPrice((int)ReceiptID, ItemID, ManufacturerID, ItemUnitID, AccountID, NewUnitCost, NewSellingPrice); }
public void RecordAverageCostAndSellingPrice(int userID) { MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { transaction.BeginTransaction(); DataTable ReceiveDocDetails; IList <CostElement> costElements = new List <CostElement>(); foreach (DataRowView drv in GRVSoundDetail.DefaultView as DataView) { double NewUnitCost, NewSellingPrice; if (drv["AverageCost"] != DBNull.Value && drv["SellingPrice"] != DBNull.Value) { CostElement costElement = new CostElement(); costElement.ItemID = Convert.ToInt32(drv["ItemID"]); costElement.ItemUnitID = Convert.ToInt32(drv["ItemUnitID"]); costElement.MovingAverageID = Convert.ToInt32(drv["MovingAverageID"]); costElement.ManufacturerID = Convert.ToInt32(drv["ManufacturerID"]); costElement.AverageCost = costElement.SellingPrice = Math.Round(Convert.ToDouble(drv["SellingPrice"]), Settings.NoOfDigitsAfterTheDecimalPoint); costElement.Margin = drv["Margin"] != DBNull.Value ? Convert.ToDouble(drv["Margin"]) : 0; ReceiveDocDetails = ReceiveDoc.GetRelatedReceiveForUnitCostAndSellingPrice(ReceiptID, costElement); foreach (DataRowView Cursor in ReceiveDocDetails.AsDataView()) { int ID = Convert.ToInt32(Cursor["ID"]); ReceiveDoc.SetAverageCostByReceiveDoc(ID, costElement.AverageCost, userID); ReceiveDoc.SetSellingPriceByReceiveDoc(ID, costElement.SellingPrice, userID); } costElements.Add(costElement); } } try { CostingService.SavePriceChange(costElements.AsEnumerable(), userID, ChangeMode.Recieve, ReceiptID.ToString()); } catch (Exception) { //Until Cost Tier Implementation } transaction.CommitTransaction(); } catch (Exception ex) { transaction.RollbackTransaction(); throw ex; } }
public DataTable BalanceAllItems(int storeId, int year, int month, string selectedType) { IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); YearEnd yEnd = new YearEnd(); Items itm = new Items(); DataTable dtResult = new DataTable(); string[] col = { "FullItemName", "BBalance", "BBAmount", "ReceivedQty", "ReceivedAmount", "IssuedQty", "IssuedAmount", "LossesQty", "LossesAmount", "AdjustedQty", "AdjustedAmount", "SOH", "SOHAmount", "Received", "ID", "CategoryId", "SubCategoryID" }; int i = 0; foreach (string s in col) { if (i > 0) { dtResult.Columns.Add(s, typeof(double)); } else { dtResult.Columns.Add(s); } i++; } DataTable dtItem = ((selectedType == "Drug") ? itm.GetAllItems(1) : itm.GetAllSupply()); foreach (DataRow dr in dtItem.Rows) { string itemName = dr["FullItemName"].ToString();// +" - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString(); int itemId = Convert.ToInt32(dr["ID"]); Int64 bb = yEnd.GetBBalance(year, storeId, itemId, month); double bbAmount = yEnd.GetBBalanceAmount(year, storeId, itemId, month); Int64 recQuant = rec.GetReceivedQuantityTillMonth(itemId, storeId, month, year); double recPrice = rec.GetReceivedAmountTillMonth(itemId, storeId, month, year); Int64 issuedQuant = iss.GetIssuedQuantityTillMonth(itemId, storeId, month, year); double issPrice = iss.GetIssuedAmountTillMonth(itemId, storeId, month, year); Int64 lossQuant = dis.GetLossesQuantityTillMonth(itemId, storeId, month, year); double lossAmount = dis.GetLossesAmountTillMonth(itemId, storeId, month, year); Int64 adjQuant = dis.GetAdjustedQuantityTillMonth(itemId, storeId, month, year); double adjAmount = dis.GetAdjustedAmountTillMonth(itemId, storeId, month, year); Int64 SOH = bb + recQuant + adjQuant - issuedQuant - lossQuant; double SOHAmount = (bbAmount + recPrice + adjAmount - issPrice) - lossAmount; if (SOHAmount < 0) { ; } int Isrec = ((bb == 0 && recQuant == 0) ? 0 : 1); object[] obj = { itemName, bb, bbAmount, recQuant, recPrice, issuedQuant, issPrice, lossQuant, lossAmount, adjQuant, adjAmount, SOH, SOHAmount, Isrec, itemId, Convert.ToInt32(dr["CategoryId"]), Convert.ToInt32(dr["SubCategoryID"]) }; dtResult.Rows.Add(obj); } return dtResult; }
private void EditRecieveRefrenceNo_Load(object sender, EventArgs e) { dtRecDate.Value = DateTime.Now; dtRecDate.CustomFormat = "MM/dd/yyyy"; var rec = new ReceiveDoc(); if(_refno!=null) { dtRecDate.ResetValue(); rec.GetTransactionByRefNo(_refno); refnotextEdit.Text = rec.RefNo; DateTime dtDate = Convert.ToDateTime(rec.Date.ToString("MM/dd/yyyy")); txtDate.Text = dtDate.ToShortDateString(); } }
private void RelatedReceipts_Load(object sender, EventArgs e) { BLL.ReceiveDoc rdoc = new ReceiveDoc(); rdoc.LoadByPrimaryKey(_reciptID); if (mode==RelatedReceiptMode.WAREHOUSE_MODE) { gridMain.DataSource = BLL.Receipt.GetRawInventoryCountbyAccountandWarehouseItem(_accountID, _warehouseID, rdoc.ItemID, rdoc.UnitID); } else if(mode==RelatedReceiptMode.PHYSICAL_STORE_MODE) { gridMain.DataSource = BLL.Receipt.GetRawInventoryCountbyAccountandPhysicalStoreItem(_accountID, _warehouseID, rdoc.ItemID, rdoc.UnitID); } }
private void btnChangeReceiptConfirmationStatus_Click(object sender, EventArgs e) { int newReceiptConfirmationStatus = int.Parse(lkReceiptConfirmationStatus.EditValue.ToString()); BLL.ReceiveDoc rd = new ReceiveDoc(); rd.LoadByReceiptID(int.Parse(txtReceiptID.Text)); while (!rd.EOF) { ReceiveDocConfirmation rdc = new ReceiveDocConfirmation(); rdc.LoadByReceiveDocID(rd.ID); rdc.ReceiptConfirmationStatusID = newReceiptConfirmationStatus; rdc.Save(); rd.MoveNext(); } XtraMessageBox.Show("Successful!"); }
/* public Int64 GetBBalanceAll(int year, int itemId) * { * this.FlushData(); * this.LoadFromRawSql(String.Format("Select * from YearEnd where ItemID = {0} AND Year = {1}", itemId, year)); * * Int64 bb = (this.DataTable.Rows.Count > 0) ? Convert.ToInt64(this.DataTable.Rows[0]["BBalance"]) : 0; * * return bb; * }*/ /// <summary> /// Gets the beginning balance of an item in a store /// </summary> /// <param name="fiscalYear">The Fiscal year in Ethiopian Calendar</param> /// <param name="storeId"></param> /// <param name="itemId"></param> /// <returns></returns> public Int64 GetBBalance(int fiscalYear, int storeId, int itemId) { //CALENDAR: this.FlushData(); Int64 bb = 0; int year = fiscalYear; int month = 10; string query = String.Format( "Select * from YearEnd where StoreID = {0} AND ItemID = {1} AND Year = {2} order by PhysicalInventory desc", storeId, itemId, fiscalYear - 1); this.LoadFromRawSql(query); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else { if (((year + 8) > DateTime.Now.Year) || (month > 10 && (year + 8) == DateTime.Now.Year)) // to check if it is different year from current { Int64 cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); if ((year + 8) > DateTime.Now.Year) // to check if it is hamle and Nehase { year = year - 1; } month = 10; //} long RecievedQuantity = rec.GetReceivedQuantityTillMonth(itemId, storeId, month, year); long AdjustedQuantity = dis.GetAdjustedQuantityTillMonth(itemId, storeId, month, year); long IssuedQuantity = iss.GetIssuedQuantityTillMonth(itemId, storeId, month, year); long LossQuantity = dis.GetLossesQuantityTillMonth(itemId, storeId, month, year); // long BalanceQuantity = yEnd.GetBBalance(year, storeId, itemId, month); cons = (RecievedQuantity + AdjustedQuantity - IssuedQuantity - LossQuantity); //cons = (rec.GetReceivedQuantityTillMonth(itemId, storeId, month, year) + dis.GetAdjustedQuantityTillMonth(itemId, storeId, month, year) - iss.GetIssuedQuantityTillMonth(itemId, storeId, month, year) - dis.GetLossesQuantityTillMonth(itemId, storeId, month, year)); bb = cons; } } return(bb); }
public static bool CanInventoryBeStarted(int physicalStoreID) { BLL.PhysicalStore ps = new PhysicalStore(); ps.LoadByPrimaryKey(physicalStoreID); int warehouseID = ps.PhysicalStoreTypeID; if (!ReceiveDoc.checkOutstandingReceives(warehouseID)) { return(false); } if (!IssueDoc.CheckOutStandingIssues(warehouseID)) { return(false); } return(true); }
private void btnSave_Click(object sender, EventArgs e) { string valid = ValidateFields(); if (valid == "true") { if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); iss.LoadByPrimaryKey(_tranId); string batchNo = iss.BatchNo; Int64 qty = iss.Quantity; rec.GetTransactionByBatch(iss.ItemID, iss.BatchNo, iss.StoreId); iss.RefNo = txtRefNo.Text; iss.BatchNo = txtBatchNo.Text; iss.NoOfPack = Convert.ToInt32(txtPack.Text); iss.QtyPerPack = Convert.ToInt32(txtQtyPack.Text); iss.Quantity = Convert.ToInt32(txtPack.Text) * Convert.ToInt32(txtQtyPack.Text); iss.StoreId = Convert.ToInt32(cboStores.SelectedValue); iss.ReceivingUnitID = Convert.ToInt32(cboReceivingUnit.SelectedValue); iss.Remark = txtRemark.Text; iss.IssuedBy = txtReceivedBy.Text; iss.Save(); Int64 newQty = 0; if(qty > iss.Quantity) newQty = rec.QuantityLeft + (qty - iss.Quantity); else newQty = rec.QuantityLeft - (iss.Quantity - qty); rec.QuantityLeft = newQty; if(rec.QuantityLeft >0) rec.Out = false; rec.Save(); XtraMessageBox.Show("Transaction Succsfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { XtraMessageBox.Show(valid, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
public DataRow IsItemBeingPricedElsewhere() { DataTable List; foreach (DataRowView drv in GRVDetail.DefaultView) { List = ReceiveDoc.ListOfItemPendingPrintAndConfirmation(Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["MovingAverageID"])); if (List.Rows.Count > 0) { return(List.Rows[0]); } } return(null); }
/// <summary> /// Undo pick list that has been printed /// </summary> /// <param name="orderID">The order ID.</param> public void CancelOrderWithPickList(int orderID) { // Create a pick list entry Order ord = new Order(); PickList pl = new PickList(); PickListDetail pld = new PickListDetail(); ReceivePallet rp = new ReceivePallet(); ReceiveDoc rd = new ReceiveDoc(); PickFace pf = new PickFace(); PalletLocation palletLocation = new PalletLocation(); ord.LoadByPrimaryKey(orderID); pl.LoadByOrderID(orderID); pld.LoadByPickListID(pl.ID); while (!pld.EOF) { rp.LoadByPrimaryKey(pld.ReceivePalletID); rp.ReservedStock -= Convert.ToInt32(pld.QuantityInBU); if (rp.ReservedStock < 0) { rp.ReservedStock = 0; //If there has been no reservation, allow to cancel the picklist too. No need for it to be blocked by the constraint. } rp.Save(); palletLocation.LoadByPrimaryKey(pld.PalletLocationID); if (palletLocation.StorageTypeID.ToString() == StorageType.PickFace) { pf.LoadByPalletLocation(pld.PalletLocationID); pf.Balance += Convert.ToInt32(pld.QuantityInBU); pf.Save(); } //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); pld.MoveNext(); } pld.Save(); ord.ChangeStatus(OrderStatus.Constant.CANCELED, CurrentContext.UserId); pl.MarkAsDeleted(); pl.Save(); }
/// <summary> /// Adds a new delete log /// </summary> /// <param name="deletedReceiveDoc">The ReceiveDoc object to be deleted</param> /// <param name="deletedByUser">The user performing the deletion</param> public static ReceiveDocDeleted AddNewLog(ReceiveDoc deletedReceiveDoc, int deletedByUser) { var recLog = new ReceiveDocDeleted(); recLog.AddNew(); foreach (DataColumn col in deletedReceiveDoc.DefaultView.Table.Columns) { try { recLog.SetColumn(col.ColumnName, deletedReceiveDoc.GetColumn(col.ColumnName)); } catch { /*Till VVMID Column generated for ReceiveDocDeleted! */} } recLog.DeletedBy = deletedByUser; recLog.DateDeleted = DateTimeHelper.ServerDateTime; return recLog; }
/// <summary> /// Adds a new delete log /// </summary> /// <param name="deletedReceiveDoc">The ReceiveDoc object to be deleted</param> /// <param name="deletedByUser">The user performing the deletion</param> public static ReceiveDocDeleted AddNewLog(ReceiveDoc deletedReceiveDoc, int deletedByUser) { var recLog = new ReceiveDocDeleted(); recLog.AddNew(); foreach (DataColumn col in deletedReceiveDoc.DefaultView.Table.Columns) { try { recLog.SetColumn(col.ColumnName, deletedReceiveDoc.GetColumn(col.ColumnName)); } catch { /*Till VVMID Column generated for ReceiveDocDeleted! */ } } recLog.DeletedBy = deletedByUser; recLog.DateDeleted = DateTimeHelper.ServerDateTime; return(recLog); }
/// <summary> /// Get begining balance by item, store and month /// </summary> /// <param name="year">The year.</param> /// <param name="storeId">The store id.</param> /// <param name="itemId">The item id.</param> /// <param name="month">The month.</param> /// <returns></returns> public Int64 GetBBalance(int year, int storeId, int itemId, int month) { this.FlushData(); Int64 bb = 0; int bYear = ((month > 10) ? year : year - 1); this.LoadFromRawSql(HCMIS.Repository.Queries.YearEnd.SelectGetBBalance(storeId, itemId, bYear)); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else { this.LoadFromRawSql(HCMIS.Repository.Queries.YearEnd.SelectGetBBalanceSelectElse(year, storeId, itemId)); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else if (((year + 8) > DateTimeHelper.ServerDateTime.Year) || (month > 10 && (year + 8) == DateTimeHelper.ServerDateTime.Year)) // to check if it is different year from current { Int64 cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); LossAndAdjustment dis = new LossAndAdjustment(); if ((year + 8) > DateTimeHelper.ServerDateTime.Year) // to check if it is hamle and Nehase { year = year - 1; } month = 10; //} long receivedQuantity = rec.GetReceivedQuantityTillMonth(itemId, storeId, month, year); long adjustedQuantity = dis.GetAdjustedQuantityTillMonth(itemId, storeId, month, year); long issuedQuantity = iss.GetIssuedQuantityTillMonth(itemId, storeId, month, year); long lostQuantity = dis.GetLossesQuantityTillMonth(itemId, storeId, month, year); cons = (receivedQuantity + adjustedQuantity - issuedQuantity - lostQuantity); bb = cons; } } return(bb); }
public static bool MarkReceivedBatchAsEmpty(int receiveID) { try { BLL.ReceiveDoc rec = new ReceiveDoc(); rec.LoadByPrimaryKey(receiveID); if (rec.RowCount > 0) { rec.QuantityLeft = 0; rec.Out = true; rec.Save(); return(true); } return(false); } catch { return(false); } }
public void SaveCostCoefficient(int userID) { ReceiveDoc grvFullDetail = new ReceiveDoc(); grvFullDetail.FlushData(); grvFullDetail.LoadAllByReceiptID(GRV.ID); CostBuildUp.SaveChange(); while (!grvFullDetail.EOF) { //Insurance here is costCoefficient ReceiveDoc receivedoc = new ReceiveDoc(); receivedoc.LoadByPrimaryKey(grvFullDetail.ID); //Use Custom StoreProcedure for Costing receivedoc.Insurance = CostCoefficient; receivedoc.Save(); ReceiveDoc.SetUnitCostByReceiveDoc(grvFullDetail.ID, Math.Round(receivedoc.PricePerPack * CostCoefficient, 2), userID); ReceiveDoc.SetAverageCostByReceiveDoc(grvFullDetail.ID, Math.Round(receivedoc.PricePerPack * CostCoefficient, 2), userID); grvFullDetail.MoveNext(); } }
public static bool MarkReceivedBatchAsEmpty(int receiveID) { try { BLL.ReceiveDoc rec = new ReceiveDoc(); rec.LoadByPrimaryKey(receiveID); if (rec.RowCount > 0) { rec.QuantityLeft = 0; rec.Out = true; rec.Save(); return true; } return false; } catch { return false; } }
public void GetDetailInformation() { DataTable Information = ReceiveDoc.GetItemInformation(ItemID, ItemUnitID, ManufacturerID, MovingAverageID); if (Information.Rows.Count > 0) { DataRow dr = Information.Rows[0]; _StockCode = dr["StockCode"].ToString(); _ItemName = dr["FullItemName"].ToString(); _ItemUnitName = dr["ItemUnitName"].ToString(); _ManufacturerName = dr["ManufacturerName"].ToString(); _AccountName = dr["AccountName"].ToString(); _ActivityName = dr["ActivityName"].ToString(); } else { _StockCode = _ItemName = _ItemUnitName = _ManufacturerName = _AccountName = "UnDefined"; } }
public DataView CostAnalysis(string pGRVNo) { Receipt receipt = new Receipt(ReceiptID); PO PO = receipt.ReceiptInvoice.PO; ReceiptInvoice receiptInvoice = receipt.ReceiptInvoice; ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByReceiptID(ReceiptID); Activity activity = new Activity(); activity.LoadByPrimaryKey(receiveDoc.StoreID); JournalEntry UnitCostJournal = new JournalEntry(activity.AccountName, activity.SubAccountName, activity.Name, PO.Supplier.CompanyName, "", PO.PONumber, pGRVNo, receiptInvoice.STVOrInvoiceNo, receiptInvoice.TransitTransferNo, receiptInvoice.WayBillNo, receiptInvoice.InsurancePolicyNo); double GIT = _GrandTotalCost; //When insurance is included (_TotalLandedCost-_GrandTotal) is the price effect cauzed by rounding double PriceDifference = Math.Round(_PriceDifference - _PriceDifferenceIns, Settings.NoOfDigitsAfterTheDecimalPoint); if (receiveDoc.ReturnedStock) { double stock = Math.Round(GetGrandTotalForSRM(), 2); return(SRMCostAnalysis(UnitCostJournal, _CommodityType, stock, stock, ReceiptID)); } UnitCostJournal.AddNewEntry("Stock (" + _CommodityType + ")", Math.Round(_GrandTotalCost + PriceDifference, Settings.NoOfDigitsAfterTheDecimalPoint), null); if (PriceDifference > 0) { UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference)); } else if (PriceDifference < 0) { UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null); } UnitCostJournal.AddNewEntry( "Account Payable (" + GetAccountPayableCorrectNameByAccount(_Supplier) + ")", null, Math.Round(_GrandTotalCost, Settings.NoOfDigitsAfterTheDecimalPoint)); return(UnitCostJournal.DefaultView()); }
private void cboStores_SelectedValueChanged(object sender, EventArgs e) { if (cboStores.EditValue != null) { ReceiveDoc rec = new ReceiveDoc(); DataTable dtRec = new DataTable(); dtRec = rec.GetDistinctRecDocments(Convert.ToInt32(cboStores.EditValue)); PopulateDocuments(dtRec); DateTime dt1 = new DateTime(); DateTime dt2 = new DateTime(); dtDate.Value = DateTimeHelper.ServerDateTime; DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); int yr = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1); dt1 = new DateTime(yr, 11, 1); dt2 = new DateTime(dtCurrent.Year, dtCurrent.Month, dtCurrent.Day); dtRec = rec.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dt1, dt2); PopulateTransactions(dtRec); } }
private void btnFixLocationStuff_Click(object sender, EventArgs e) { int storeID = Convert.ToInt32(lkStoreLocation.EditValue); BLL.ReceiveDoc rd = new BLL.ReceiveDoc(); rd.LoadReceivesForStores(storeID); while (!rd.EOF) { BLL.ReceivePallet rp = new BLL.ReceivePallet(); rp.LoadByReceiveDocID(rd.ID); decimal receivedQuantity = 0, balance = 0; if (rp.RowCount == 1)// rp.RowCount > 0) { while (!rp.EOF) { receivedQuantity += rp.IsColumnNull("ReceivedQuantity") ? 0 : rp.ReceivedQuantity; balance += rp.IsColumnNull("Balance") ? 0 : rp.Balance; rp.MoveNext(); } rp.Rewind(); while (!rp.EOF && rp.IsColumnNull("ReceivedQuantity")) { rp.MoveNext(); } if (rd.Quantity != receivedQuantity && rd.Quantity > receivedQuantity) { rp.ReceivedQuantity += (rd.Quantity - receivedQuantity); } if (rd.QuantityLeft != balance && rd.QuantityLeft > 0)//rd.QuantityLeft > balance) { rp.Balance += (rd.QuantityLeft - balance); } rp.Save(); } rd.MoveNext(); } XtraMessageBox.Show("Completed!"); }
public Int64 GetBBalanceAll(int year, int itemId) { this.FlushData(); Int64 bb = 0; this.LoadFromRawSql(String.Format("Select * from YearEnd where ItemID = {0} AND Year = {1}", itemId, year)); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else { this.LoadFromRawSql(String.Format("Select * from YearEnd where ItemID = {0} AND Year = {1}", itemId, year - 1)); if (this.DataTable.Rows.Count > 0) { bb = Convert.ToInt64(this.DataTable.Rows[0]["PhysicalInventory"]); } else if (((year + 8) > DateTime.Now.Year)) // to check if it is different year from current { Int64 cons = 0; IssueDoc iss = new IssueDoc(); ReceiveDoc rec = new ReceiveDoc(); Disposal dis = new Disposal(); if ((year + 8) > DateTime.Now.Year) // to check if it is hamle and Nehase { year = year - 1; } int month = 10; cons = (rec.GetReceivedQuantityTillMonthAll(itemId, month, year) + dis.GetAdjustedQuantityTillMonthAll(itemId, month, year) - iss.GetIssuedQuantityTillMonthAll(itemId, month, year) - dis.GetLossesQuantityTillMonthAll(itemId, month, year)); bb = cons; } } return(bb); }
private void PassReceiveForQtyConfirmation() { if (gridReceiveView.GetFocusedDataRow() != null) { String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString(); if (gridDetailView.DataSource == null) { return; } BLL.ReceiveDoc recDoc = new ReceiveDoc(); recDoc.LoadByReferenceNo(reference); recDoc.SetStatusAsReceived(CurrentContext.UserId); BLL.Receipt receiptStatus = new BLL.Receipt(); receiptStatus.LoadByPrimaryKey(ReceiptID); receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED, null, this.GetFormIdentifier(), CurrentContext.UserId, "Quantity edited"); XtraMessageBox.Show("Receipt forwarded for quantity confirmation!", "Success", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); BindFormContents(); } }
private void btnUpdate_Click(object sender, EventArgs e) { var rec = new ReceiveDoc(); DataTable dtbl = rec.GetTransactionByRefNo(_refno); if (rec.RowCount > 0) { foreach (DataRow datarow in dtbl.Rows) { datarow["RefNo"] = refnotextEdit.Text; datarow["Date"] = txtDate.Text; } rec.Save(); Close(); XtraMessageBox.Show("Refrence No and Date is successfully updated", "Success"); } else { XtraMessageBox.Show("There is no refrence to edit"); return; } this.Close(); }
public void SetPriceForReceiveDocs() { ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadbyItemUnitManufacturerMovingAverageID(ReceiptID.Value, ItemID, ItemUnitID, ManufacturerID, MovingAverageID); receiveDoc.Rewind(); while (!receiveDoc.EOF) { if (receiveDoc.IsColumnNull("PricePerPack") || !(receiveDoc.PricePerPack > 0)) { receiveDoc.PricePerPack = AverageCost; } if (receiveDoc.IsColumnNull("UnitCost") || !(receiveDoc.PricePerPack > 0)) { receiveDoc.UnitCost = Convert.ToDecimal(AverageCost); } receiveDoc.Cost = AverageCost; receiveDoc.Margin = Margin; receiveDoc.SellingPrice = SellingPrice; receiveDoc.MoveNext(); } receiveDoc.Save(); }
private void btnCancelReceive_Click(object sender, EventArgs e) { if (XtraMessageBox.Show(DevExpress.LookAndFeel.UserLookAndFeel.Default, "Are you sure, you want to Cancel the Receipt Document?", "Are you sure:", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes) { try { int receiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"].ToString()); var receiveDoc = new ReceiveDoc(); receiveDoc.LoadByReceiptID(receiptID); receiveDoc.Rewind(); while (!receiveDoc.EOF) { BLL.ReceiveDoc.DeleteAReceiveDocEntry(receiveDoc.ID, CurrentContext.UserId); receiveDoc.MoveNext(); } XtraMessageBox.Show("You have successfully canceled the draft receipt.", "Confirmation"); BindFormContents(); } catch (Exception exception) { XtraMessageBox.Show(exception.Message); } } }
internal void SetStatusConfirmQuantityAndLocation(int receiveID, int?userID) { LoadByReceiveDocID(receiveID); BLL.ReceiveDoc rcDoc = new ReceiveDoc(); BLL.Receipt rct = new Receipt(); rcDoc.LoadByPrimaryKey(receiveID); rct.LoadByPrimaryKey(rcDoc.ReceiptID); if (RowCount == 0) { AddNew(); ReceiveDocID = receiveID; } if (userID.HasValue) { ReceiptQuantityConfirmedByUserID = userID.Value; } ReceiptConfirmationStatusID = rct.ReceiptTypeID == BLL.ReceiptType.CONSTANTS.BEGINNING_BALANCE? ReceiptConfirmationStatus.Constants.GRV_PRINTED: ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED; Save(); }
private void btnDispose_Click(object sender, EventArgs e) { if (!dxValidationProvider1.Validate()) return; TransferService transferService = new TransferService(); IssueService issueService = new IssueService(); if (XtraMessageBox.Show("Please Confirm that you want to dispose the selected items", "Warning", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { int activityID = Convert.ToInt32(glkActivity.EditValue); var dt = (DataView)grdSelectedExpiredItemsView.DataSource; Order order = OrderForDisposal(activityID); PickList picklist = PickList.GeneratePickList(order.ID); BLL.Issue stvLog = issueService.CreateSTVLog(null, false, picklist, order, null, activityID, false, CurrentContext.UserId); foreach (DataRow row in dt.Table.Rows) { ReceiveDoc rd = new ReceiveDoc(); ReceivePallet rp = new ReceivePallet(); rd.LoadByPrimaryKey((int)row["ReceiveDocID"]); rp.LoadByReceiveDocID((int)row["ReceiveDocID"]); var picklistDetail = transferService.GeneratePickListDetail(rd, rp, order, picklist); issueService.CreateIssueFromPicklist(picklistDetail, order, DateTime.Now, stvLog, CurrentContext.LoggedInUser); } HCMIS.Reports.Workflow.Activities.Disposal disposalPrintout = new HCMIS.Reports.Workflow.Activities.Disposal(glkActivity.Text, txtLicenseNo.Text, DateTime.Now, ((DataView)grdSelectedExpiredItemsView.DataSource).Table); disposalPrintout.PrintDialog(); RefreshSelection(); txtLicenseNo.ResetText(); } }
private void btnSave_Click(object sender, EventArgs e) { ReceiveDoc rd = new ReceiveDoc(); if (!confirmation) { rs.NewUnitCost = Convert.ToDouble(txtAverageCost.EditValue); rs.Margin = Convert.ToDouble(txtMargin.EditValue); rs.NewSellingPrice = Convert.ToDouble(txtSellingPrice.EditValue); rs.NewPrice = rs.NewSellingPrice; // set the item as weighted average item Item itm = new Item(); itm.LoadByPrimaryKey(ItemID); itm.IsFree = false; itm.Save(); rd.SavePrice(rs, CurrentContext.UserId); //if (!StoreType.IsFreeStore(StoreID)) //{ // //Change the cost // rs.NewCost = rs.NewUnitCost; // rd.SaveNewCost(rs, NewMainWindow.UserId); //} //----------- XtraMessageBox.Show("New Price setting has been saved.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { rd.ConfirmMovingAverage(rs, CurrentContext.UserId); } this.Close(); }
private void returnToBulkStoreToolStripMenuItem_Click(object sender, EventArgs e) { DataRow dr = gridPickFaceDetailView.GetFocusedDataRow(); if (dr != null) { int ReceivePalletID = Convert.ToInt32(dr["ID"]); ReceivePallet rp = new ReceivePallet(); rp.LoadByPrimaryKey(ReceivePalletID); ReceiveDoc rd = new ReceiveDoc(); rd.LoadByPrimaryKey(rp.ReceiveID); BLL.ItemManufacturer imf = new BLL.ItemManufacturer(); imf.LoadIMbyLevel(rd.ItemID, rd.ManufacturerId, rp.BoxSize); int QuantityToReturn = Convert.ToInt32(((rp.Balance - rp.ReservedStock) / imf.QuantityInBasicUnit) * imf.QuantityInBasicUnit); InternalTransfer itfr = new InternalTransfer(); } }
private void OnReplenishClicked(object sender, EventArgs e) { PalletLocation pl = new PalletLocation(); PickFace pf = new PickFace(); DataRow dr = gridPickFaceStockLevelView.GetFocusedDataRow(); DataRow dr2 = gridReplenishmentChoiceView.GetFocusedDataRow(); if (dr2 != null) { // check if the replenishment is from allowed location. // if (!Convert.ToBoolean(dr2["CanReplenish"])) { XtraMessageBox.Show("Please choose replenishment from the first to expire items", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } pl.LoadByPrimaryKey(_palletLocationID); pf.LoadByPrimaryKey(_pickFaceID); if (pf.IsColumnNull("Balance")) { pf.Balance = 0; } if (pl.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.StorageTypeID = Convert.ToInt32(StorageType.PickFace); pallet.Save(); pl.PalletID = pallet.ID; pl.Save(); } ReceivePallet rp = new ReceivePallet(); ReceivePallet rp2 = new ReceivePallet(); ReceiveDoc rd = new ReceiveDoc(); rp.LoadByPrimaryKey(Convert.ToInt32(dr2["ReceivePalletID"])); rp2.AddNew(); rp2.IsOriginalReceive = false; rp2.PalletID = pl.PalletID; rp2.ReceiveID = rp.ReceiveID; rp2.BoxSize = rp.BoxSize; // calculate the new balance BLL.ItemManufacturer im = new BLL.ItemManufacturer(); im.LoadIMbyLevel(_designatedItemID, Convert.ToInt32(dr2["ManufacturerID"]),Convert.ToInt32(dr2["BoxSize"])); if (rp.IsColumnNull("ReservedStock")) { rp.ReservedStock = 0; } //if (rp.Balance - rp.ReservedStock < im.QuantityInBasicUnit ) //{ // XtraMessageBox.Show("You cannot replenish the pick face from this location because the items are reserved for Issue. Please replenish from another receive.","Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); // return; //} BLL.ItemManufacturer imff = new BLL.ItemManufacturer(); imff.LoadOuterBoxForItemManufacturer(im.ItemID,im.ManufacturerID); if (imff.PackageLevel > im.PackageLevel && rp.Balance < imff.QuantityInBasicUnit) { rp2.Balance = rp.Balance; } else if (rp.Balance - rp.ReservedStock > im.QuantityInBasicUnit) { rp2.ReceivedQuantity = rp2.Balance = im.QuantityInBasicUnit; } else { rp2.Balance = rp.Balance; } rp2.ReservedStock = 0; rp.Balance -= rp2.Balance; if (rp.IsColumnNull("ReceivedQuantity")) { rp.ReceivedQuantity = rp.Balance + rp2.Balance; } rp.ReceivedQuantity -= rp2.Balance; rp.Save(); rp2.Save(); pl.Confirmed = false; pl.Save(); pf.Balance += Convert.ToInt32(rp2.Balance); pf.Save(); PalletLocation pl2 = new PalletLocation(); pl2.LoadLocationForPallet(rp.PalletID); rd.LoadByPrimaryKey(rp2.ReceiveID); // Now update the screen accordingly. dr["Balance"] = pf.Balance;// Convert.ToInt32(dr["Balance"]) + rp2.Balance; InternalTransfer it = new InternalTransfer(); it.AddNew(); it.ItemID = _designatedItemID; it.BoxLevel = im.PackageLevel; it.ExpireDate = rd.ExpDate; it.BatchNumber = rd.BatchNo; it.ManufacturerID = im.ManufacturerID; it.FromPalletLocationID = pl2.ID; it.ToPalletLocationID = _palletLocationID; it.IssuedDate = DateTimeHelper.ServerDateTime; it.QtyPerPack = im.QuantityInBasicUnit; it.Packs = 1; it.ReceiveDocID = rp.ReceiveID; it.QuantityInBU = it.Packs * it.QtyPerPack; it.Type = "PickFace"; it.Status = 0; it.Save(); BindPickFaceDetailAndReplenismehmnent(); XtraMessageBox.Show("Your Pick Face is updated, please print the replenishment list and confirm the stock movement", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void GenerateStockStatusPieChart() { ReceiveDoc rec = new ReceiveDoc(); progressBar1.Visible = true; chartPie.UseWaitCursor = true; chartPie.Series.Clear(); int storeId = (cboStores.SelectedValue != null) ? Convert.ToInt32(cboStores.SelectedValue) : 0; int neverRec = rec.CountNeverReceivedItems(storeId); curYear = Convert.ToInt32(cboYear.SelectedItem); curMont = (curYear == dtCurrent.Year) ? dtCurrent.Month : 12; progressBar1.PerformStep(); DataTable dtList = new DataTable(); dtList.Columns.Add("Type"); dtList.Columns.Add("Value"); dtList.Columns[1].DataType = typeof(Int64); //TODO: the pie has to display something doesn't it? Series ser = new Series("pie", ViewType.Pie3D); ser.DataSource = dtList; ser.ArgumentScaleType = ScaleType.Qualitative; ser.ArgumentDataMember = "Type"; ser.ValueScaleType = ScaleType.Numerical; ser.ValueDataMembers.AddRange(new string[] { "Value" }); ser.PointOptions.PointView = PointView.ArgumentAndValues; ser.LegendText = "Key"; ser.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; ser.PointOptions.ValueNumericOptions.Precision = 0; progressBar1.PerformStep(); ((PieSeriesLabel)ser.Label).Position = PieSeriesLabelPosition.TwoColumns; ((PiePointOptions)ser.PointOptions).PointView = PointView.ArgumentAndValues; chartPie.Series.Add(ser); chartPie.Size = new System.Drawing.Size(1000, 500); progressBar1.PerformStep(); lblHeader.Text = GeneralInfo.Current.HospitalName + " Stock Status summary of year " + curYear + " of " + cboStores.Text; progressBar1.Visible = false; chartPie.UseWaitCursor = false; }
public List<Order> GetStandardRRFOrders() { var client = new ServiceRRFLookupClient(); var orders = new List<Order>(); var ginfo = new GeneralInfo(); ginfo.LoadAll(); var dataView = gridItemChoiceView.DataSource as DataView; if (dataView != null) { dataView.RowFilter = gridItemChoiceView.ActiveFilterString; tblRRF = dataView.ToTable(); } var periods = client.GetCurrentReportingPeriod(ginfo.FacilityID, ginfo.ScmsWSUserName, ginfo.ScmsWSPassword); var form = client.GetForms(ginfo.FacilityID, ginfo.ScmsWSUserName, ginfo.ScmsWSPassword); var rrfs = client.GetFacilityRRForm(ginfo.FacilityID, form[0].Id, periods[0].Id, 1, ginfo.ScmsWSUserName, ginfo.ScmsWSPassword); var formCategories = rrfs.First().FormCategories; var chosenCategoryBody = formCategories.First(x => x.Id == 1); //TODO:Hard coding to be removed. var items = chosenCategoryBody.Pharmaceuticals; var user = new User(); user.LoadByPrimaryKey(MainWindow.LoggedinId); var order = new Order { RequestCompletedDate = DateTime.Now, OrderCompletedBy = user.FullName, RequestVerifiedDate = DateTime.Now, OrderTypeId = STANDARD_ORDER, SubmittedBy = user.FullName, SubmittedDate = DateTime.Now, SupplyChainUnitId = ginfo.FacilityID, OrderStatus = 1, //TODO: hardcoding FormId = form[0].Id, //TODO: hardcoding ReportingPeriodId = periods[0].Id //TODO: hardcoding }; var details = new List<RRFTransactionService.OrderDetail>(); foreach (DataRow rrfLine in tblRRF.Rows) { var detail = new RRFTransactionService.OrderDetail(); var hcmisItemID = Convert.ToInt32(rrfLine["DSItemID"]); var rrFormPharmaceutical = items.SingleOrDefault(x => x.PharmaceuticalId == hcmisItemID); if (rrFormPharmaceutical != null && Convert.ToString(rrfLine["Status"]) != "Below EOP") { detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]); detail.EndingBalance = Convert.ToInt32(rrfLine["SOH"]); detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]); detail.QuantityOrdered = Convert.ToInt32(rrfLine["Quantity"]); detail.LossAdjustment = Convert.ToInt32(rrfLine["LossAdj"]); detail.ItemId = rrFormPharmaceutical.ItemId; var rdDoc = new ReceiveDoc(); var disposal = new Disposal(); rdDoc.GetAllWithQuantityLeft(hcmisItemID, _storeID); disposal.GetLossAdjustmentsForLastRrfPeriod(hcmisItemID, _storeID, periods[0].StartDate, periods[0].EndDate); int receiveDocEntries = rdDoc.RowCount; int disposalEntries = disposal.RowCount; if (rdDoc.RowCount == 0 && detail.EndingBalance == 0) detail.Expiries = null; detail.Expiries = new Expiry[receiveDocEntries]; detail.Adjustments = new Adjustment[disposalEntries]; rdDoc.Rewind(); int expiryAmountTotal = 0; for (int j = 0; j < receiveDocEntries; j++) { var exp = new Expiry { Amount = Convert.ToInt32(rdDoc.QuantityLeft) }; expiryAmountTotal += exp.Amount; exp.BatchNo = rdDoc.BatchNo; exp.ExpiryDate = rdDoc.ExpDate; if(exp.ExpiryDate > periods[0].EndDate.AddDays(ExpiryTreshHold)) exp.Amount = Convert.ToInt32(rdDoc.QuantityLeft); exp.ExpiryDate = periods[0].EndDate; detail.Expiries[j] = exp; rdDoc.MoveNext(); } disposal.Rewind(); int lossadjamt = 0; for (int j = 0; j < disposalEntries; j++) { var adj = new Adjustment { Amount = Convert.ToInt32(disposal.Quantity), TypeId = 1, ReasonId = 1 }; lossadjamt += adj.Amount; if (lossadjamt >= detail.LossAdjustment) detail.LossAdjustment = lossadjamt; detail.Adjustments[j] = adj; disposal.MoveNext(); } var stockoutIndexedLists = StockoutIndexBuilder.Builder.GetStockOutHistory(hcmisItemID, _storeID); var DOSPerStockOut = stockoutIndexedLists.Count(); detail.DaysOutOfStocks = new DaysOutOfStock[stockoutIndexedLists.Count()]; for (int j = 0; j < stockoutIndexedLists.Count(); j++) { var dos = new DaysOutOfStock { NumberOfDaysOutOfStock = 5, StockOutReasonId = 5 }; detail.DaysOutOfStocks[j] = dos; } } else if(rrFormPharmaceutical != null && Convert.ToString(rrfLine["Status"]) == "Below EOP") { detail.BeginningBalance = null; detail.EndingBalance = null; detail.QuantityReceived = null; detail.QuantityOrdered = null; detail.LossAdjustment = null; detail.ItemId = rrFormPharmaceutical.ItemId; var rdDoc = new ReceiveDoc(); var disposal = new Disposal(); rdDoc.GetAllWithQuantityLeft(hcmisItemID, _storeID); disposal.GetLossAdjustmentsForLastRrfPeriod(hcmisItemID, _storeID, periods[0].StartDate,periods[0].EndDate); int receiveDocEntries = rdDoc.RowCount; int disposalEntries = disposal.RowCount; if (rdDoc.RowCount == 0 && detail.EndingBalance == 0) detail.Expiries = null; detail.Expiries = new Expiry[receiveDocEntries]; detail.Adjustments = new Adjustment[disposalEntries]; rdDoc.Rewind(); int expiryAmountTotal = 0; for (int j = 0; j < receiveDocEntries; j++) { var exp = new Expiry {Amount = Convert.ToInt32(rdDoc.QuantityLeft)}; expiryAmountTotal += exp.Amount; exp.BatchNo = rdDoc.BatchNo; exp.ExpiryDate = rdDoc.ExpDate; if (expiryAmountTotal >= detail.EndingBalance) if (detail.EndingBalance != null) exp.Amount = exp.Amount - (expiryAmountTotal - detail.EndingBalance.Value); detail.Expiries[j] = null; rdDoc.MoveNext(); } disposal.Rewind(); int lossadjamt = 0; for (int j = 0; j < disposalEntries; j++) { var adj = new Adjustment { Amount = Convert.ToInt32(disposal.Quantity), TypeId = 11, ReasonId = 39 }; lossadjamt += adj.Amount; if (lossadjamt >= detail.LossAdjustment) detail.LossAdjustment = lossadjamt; detail.Adjustments[j] = null; disposal.MoveNext(); } var stockoutIndexedLists = StockoutIndexBuilder.Builder.GetStockOutHistory(hcmisItemID, _storeID); var DOSPerStockOut = stockoutIndexedLists.Count(); detail.DaysOutOfStocks = new DaysOutOfStock[stockoutIndexedLists.Count()]; for (int j = 0; j < stockoutIndexedLists.Count(); j++) { var dos = new DaysOutOfStock(); dos.NumberOfDaysOutOfStock = 5; dos.StockOutReasonId = 5; detail.DaysOutOfStocks[j] = null; } } details.Add(detail); } order.OrderDetails = details.ToArray(); orders.Add(order); // loop through each record and create order & order details objects return orders; }
/// <summary> /// Issues the valid. /// </summary> /// <returns></returns> private bool IssueValid() { //check approved against // check if the order has not alrady been printed Order Order = new Order(); Order.LoadByPrimaryKey(_orderID); if (Order.OrderStatusID < OrderStatus.Constant.PICK_LIST_CONFIRMED) { XtraMessageBox.Show("Order is not yet ready for printing Invoice"); return false; } else if (Order.OrderStatusID == OrderStatus.Constant.ISSUED) { XtraMessageBox.Show("This Order has already been printed. Please select another one."); return false; } else if (Order.OrderStatusID == OrderStatus.Constant.CANCELED) { XtraMessageBox.Show("This Order has been canceled. Please select another one."); return false; } bool valid = true; DataView pl = gridOutstandingPicklistDetail.DataSource as DataView; foreach (DataRowView drv in pl) { ReceiveDoc rd = new ReceiveDoc(); drv.Row.ClearErrors(); if (drv["SKUPICKED"] == null || drv["SKUPICKED"] == DBNull.Value) { drv.Row.SetColumnError("SKUPICKED", @"Field cannot be left empty"); valid = false; } else if (Convert.ToInt32(drv["SKUPICKED"]) > Convert.ToInt32(drv["SKUTOPICK"])) { drv.Row.SetColumnError("SKUPICKED", @"You cannot issue more amount than the Approved Quantity"); valid = false; } else if (BLL.Settings.BlockWhenExpectingPriceChange && BLL.ReceiveDoc.DoesPriceNeedToBeChanged(int.Parse(drv["StoreID"].ToString()), int.Parse(drv["ItemID"].ToString()), int.Parse(drv["UnitID"].ToString()), int.Parse(drv["ManufacturerID"].ToString())) && Convert.ToInt32(drv["SKUPICKED"]) > 0) //rd.IsInNonPricedItemsList(int.Parse(drv["ItemID"].ToString())) && Convert.ToInt32(drv["SKUPICKED"]) > 0) { drv.Row.SetColumnError("FullItemName", @"Price Pending!"); Item itm = new Item(); itm.LoadByPrimaryKey(int.Parse(drv["ItemID"].ToString())); XtraMessageBox.Show(string.Format("The item {0} cannot be issued because it is waiting for price change.", itm.FullItemName), "Price Pending", MessageBoxButtons.OK, MessageBoxIcon.Warning); valid = false; } } if (Order.PaymentTypeID != PaymentType.Constants.CASH && Order.PaymentTypeID != PaymentType.Constants.CREDIT && Order.PaymentTypeID != PaymentType.Constants.STV) { //TODO: This needs to be handled well. XtraMessageBox.Show( string.Format("PaymentTypeID has a problem. The order has a payment type id of {0}", Order.PaymentTypeID.ToString()), "Payment Type ID Problem"); btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement); valid = false; } if (valid) { valid = dxValidationProvider1.Validate(); } return valid; }
private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { // Bind the detail grid PalletLocation pl = new PalletLocation(); if (e != null && e.PrevFocusedRowHandle < -1) { return; } try { DataRow dr = gridReceiveView.GetFocusedDataRow(); if (dr == null) { return; } ReceiptID = Convert.ToInt32(dr["ReceiptID"]); BLL.Receipt receiptDoc = new BLL.Receipt(); receiptDoc.LoadByPrimaryKey(ReceiptID); DataTable GRNFDetail = receiptDoc.GetDetailsForGRNF(); if (GRNFDetail.Rows.Count > 0) { //var store = new Store(); //store. BLL.PO order = new BLL.PO(); //var Mode = new Mode(); //Mode.LoadByPrimaryKey(order.ModeID); //lblMode.Text = Mode.TypeName; HeaderSection.Text = GRNFDetail.Rows[0]["PONumber"].ToString(); lblRecieveStatus.Text = dr["recieveStatus"].ToString(); lblReceiptNo.Text = dr["ReceiptNo"].ToString(); lblRecievedBy.Text = dr["ReceivedBy"].ToString(); lblRecievedDate.Text = Convert.ToDateTime(dr["Date"]).ToShortDateString(); lblReciveType.Text = (dr["ReceiveType"]).ToString(); lblWayBill.Text = (dr["WayBillNo"]).ToString() != "" ? dr["WayBillNo"].ToString() : "-"; lblTransferVoucherNo.Text = (dr["transferNo"]).ToString() != "" ? dr["transferNo"].ToString() : "-"; var warehouse = new BLL.Warehouse(); warehouse.LoadByPrimaryKey(receiptDoc.WarehouseID); lblWarehouse.Text = warehouse.Name; lblSupplier.Text = dr["Supplier"].ToString(); var cluster = new BLL.Cluster(); cluster.LoadByPrimaryKey(warehouse.ClusterID); lblCluster.Text = cluster.Name; lblDocType.Text = ""; lblPoType.Text = dr["POType"].ToString(); //var ps = new BLL.PhysicalStore(); //ps.LoadByPrimaryKey(order.p); //lblStore.Text = ps.Name; txtOrderNo.EditValue = GRNFDetail.Rows[0]["PONumber"]; lblPoNumber.Text = GRNFDetail.Rows[0]["PONumber"].ToString(); lblInvoiceNumber.Text = receiptDoc.STVOrInvoiceNo; lblInsurancePolicy.Text = receiptDoc.InsurancePolicyNo != ""?receiptDoc.InsurancePolicyNo : "-"; var activity = new Activity(); activity.LoadByPrimaryKey(Convert.ToInt32(GRNFDetail.Rows[0]["ActivityID"])); txtActivity.EditValue = activity.FullActivityName; lblActivity.Text = activity.Name; lblSubAccount.Text = activity.SubAccountName; lblMode.Text = activity.ModeName; lblAccount.Text = activity.AccountName; gridDetails.DataSource = GRNFDetail; } if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID)) { gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF(); } } catch { gridDetails.DataSource = null; } }
private void btnSetNewPrice_Click(object sender, EventArgs e) { bool validated = false; ReceiveDoc rd = new ReceiveDoc(); validated = dxValidationProviderPrice.Validate(); if (!validated) { XtraMessageBox.Show("Please fill in all required fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!isConfirmation) { if (XtraMessageBox.Show("Are u sure, you want to save the new price change?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); transactionMgr.BeginTransaction(); try { rs.NewUnitCost = Convert.ToDouble(txtAverageCost.EditValue); rs.Margin = Convert.ToDouble(txtMargin.EditValue); rs.NewSellingPrice = Convert.ToDouble(txtSellingPrice.EditValue); rs.NewPrice = rs.NewSellingPrice; //rs.Remark = txtRemark.EditValue.ToString(); // set the item as weighted average item Item itm = new Item(); itm.LoadByPrimaryKey(rs.ItemID); itm.IsFree = false; itm.Save(); rd.SavePrice(rs, CurrentContext.UserId); transactionMgr.CommitTransaction(); XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { transactionMgr.RollbackTransaction(); XtraMessageBox.Show("Price setting failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); throw ex; } } } else { if (XtraMessageBox.Show("Are you sure you want to approve the new price change.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { rd.ConfirmMovingAverage(rs, CurrentContext.UserId); XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information); } } ResetForm(); }
private void BindConsolidation() { ReceiveDoc rd = new ReceiveDoc(); rd.LoadUniqueReceivedItems(); gridItems.DataSource = rd.DefaultView; }
/// <summary> /// Gets the pick list details for order. /// </summary> /// <param name="ordID">The ord ID.</param> /// <param name="Preparedby">The preparedby.</param> /// <returns></returns> public DataView GetPickListDetailsForOrder(int ordID, string Preparedby) { this.LoadByOrderID(ordID); var query = HCMIS.Repository.Queries.PickList.SelectGetPickListDetailsForOrder(this.ID); this.LoadFromRawSql(query); // Add important columns this.DataTable.Columns.Add("SKUTOPICK", typeof(decimal)); this.DataTable.Columns.Add("SKUPICKED", typeof(decimal)); this.DataTable.Columns.Add("BUPICKED", typeof(decimal)); this.DataTable.Columns.Add("BoxSizeDisplay"); this.DataTable.Columns.Add("SKUBU", typeof(decimal)); this.DataTable.Columns.Add("IsManufacturerLocal", typeof(bool)); this.DataTable.Columns.Add("PrintedSTVNumber", typeof(string)); this.DataTable.Columns.Add("PhysicalStoreName", typeof(string)); this.DataTable.Columns.Add("PhysicalStoreTypeID", typeof(int)); this.DataTable.Columns.Add("PhysicalStoreTypeName", typeof(string)); this.DataTable.Columns.Add("PreparedBy", typeof(string)); int i = 1; while (!this.EOF) { decimal packs = Convert.ToDecimal(this.GetColumn("Packs")); int manufacturer = Convert.ToInt32(this.GetColumn("ManufacturerID")); Manufacturer m = new Manufacturer(); m.LoadByPrimaryKey(manufacturer); if (!m.IsColumnNull("CountryOfOrigin") && m.CountryOfOrigin.Contains("Ethiopia")) { this.SetColumn("IsManufacturerLocal", true); } else { this.SetColumn("IsManufacturerLocal", false); } int recPalletID = Convert.ToInt32(this.GetColumn("ReceivePalletID")); ReceivePallet rp = new ReceivePallet(); rp.LoadByPrimaryKey(recPalletID); try { ReceiveDoc receiveDoc = new ReceiveDoc(); Receipt receipt = new Receipt(); receiveDoc.LoadByPrimaryKey(rp.ReceiveID); receipt.LoadByPrimaryKey(receiveDoc.ReceiptID); this.SetColumn("PhysicalStoreName", rp.GetPhysicalStoreName()); int physicalStoreTypeID = rp.GetPhysicalStoreTypeID(); this.SetColumn("PhysicalStoreTypeID", physicalStoreTypeID); Warehouse phyStoreType = new Warehouse(); phyStoreType.LoadByPrimaryKey(physicalStoreTypeID); this.SetColumn("PhysicalStoreTypeName", phyStoreType.Name); if (BLL.Settings.PrintUserNameOnInvoice) { this.SetColumn("PreparedBy", Preparedby); } } catch { } int itemId = Convert.ToInt32(this.GetColumn("ItemID")); int boxLevel = Convert.ToInt32(this.GetColumn("BoxLevel")); decimal qtyPerPack = this.Getint("QtyPerPack"); //im.LoadIMbyLevel(itemId, manufacturer, boxLevel); this.SetColumn("SKUTOPICK", (packs)); this.SetColumn("SKUPICKED", this.GetColumn("SKUTOPICK")); // TODO:show the box size here for Program store this.SetColumn("BoxSizeDisplay", ""); this.SetColumn("SKUBU", qtyPerPack); this.SetColumn("BUPICKED", qtyPerPack * Convert.ToDecimal(this.GetColumn("SKUPICKED"))); this.SetColumn("LineNum", i++); if (this.IsColumnNull("DeliveryNote")) { this.SetColumn("DeliveryNote", false); } this.MoveNext(); } return(this.DefaultView); }
private void BindDetails(DataRow dr) { // txtAdditionalCost.EditValue = 0; //txtMargin.EditValue = 100; try { Convert.ToInt16(dr["ItemID"]); } catch { ResetForm(); return; } if (dr != null) { rs = new ReceivedSummary(); ReceiveDoc rd = new ReceiveDoc(); rs.ItemID = Convert.ToInt32(dr["ItemID"]); rs.SupplierID = Convert.ToInt32(dr["SupplierID"]); rs.ManufacturerID = Convert.ToInt32(dr["ManufacturerID"]); rs.UnitID= null; if (dr["UnitID"] != DBNull.Value) { rs.UnitID = Convert.ToInt32(dr["UnitID"]); } rs.StoreID = Convert.ToInt32(lkAccount.EditValue); // TODO: fix this ( Remove ) try cache try { txtUnit.Text = dr["Unit"].ToString(); } catch { } txtItemName.Text = dr["FullItemName"].ToString(); txtManufacturer.Text = dr["Manufacturer"].ToString(); rd.LoadForPricing(rs.ItemID, rs.SupplierID,rs.StoreID, rs.ManufacturerID, rs.UnitID); gridAllSimilarItems.DataSource = rd.DefaultView; LoadDecimalFormatings(); rs.MovingAverageTable(rs.ItemID, rs.StoreID,rs.SupplierID, rs.ManufacturerID, rs.UnitID); txtAverageCost.EditValue = rs.NewUnitCost; txtMargin.EditValue = rs.Margin; txtSellingPrice.EditValue = rs.NewSellingPrice; } }
private object GetForPrint(DataView dv) { DataTable dtbl = dv.Table.Clone(); dtbl.Columns.Add("Supplier"); dtbl.Clear(); foreach (DataRowView drv in dv) { if (dtbl.Rows.Count == 0) { dtbl.ImportRow(drv.Row); } else { //check if items with same expiry esists in the table DataRow[] ar = dtbl.Select(string.Format("ItemID={0} and BatchNumber='{1}' and UnitPrice = {2}", drv["ItemID"], drv["BatchNumber"], drv["UnitPrice"])); if (ar.Length > 0) { ar[0]["SKUPICKED"] = Convert.ToInt32(ar[0]["SKUPICKED"]) + Convert.ToInt32(drv["SKUPICKED"]); ar[0]["Cost"] = Convert.ToInt32(ar[0]["Cost"]) + Convert.ToInt32(drv["Cost"]); ar[0].EndEdit(); } else { dtbl.ImportRow(drv.Row); } } } Supplier supplier = new Supplier(); ReceiveDoc rd = new ReceiveDoc(); foreach (DataRow drw in dtbl.Rows) { rd.LoadByPrimaryKey(Convert.ToInt32(drw["ReceiveDocID"])); if (rd.RowCount > 0) { supplier.LoadByPrimaryKey(rd.SupplierID); drw["Supplier"] = supplier.CompanyName; drw.EndEdit(); } } return dtbl; }
public void rgPricing_EditValueChanged(object sender, EventArgs e) { rs.StoreID = Convert.ToInt32(lkAccount.EditValue); ReceiveDoc rd = new ReceiveDoc(); //Populate Left Grid depending on the if (rgPricingMode.EditValue.ToString() == "Items") rd.LoadAllNonPricedItems(rs.StoreID, isConfirmation); else if (rgPricingMode.EditValue.ToString() == "AllItems") rd.LoadAllPricedReceives(rs.StoreID); gridMainLeft.MainView = gridItemView; gridMainLeft.DataSource = rd.DefaultView; (gridMainLeft.MainView as GridView).ExpandAllGroups(); ChangeLayoutByMode(); }
public Collection<Order> GetOrders() { var orders = new Collection<Order>(); _tblRrf = (DataTable)gridItemsChoice.DataSource; tblRRF = (DataTable)gridItemsChoice.DataSource; var info = new GeneralInfo(); info.LoadAll(); var client1 = new ServiceRRFLookupClient(); var req = new GetCurrentReportingPeriodRequest { Password = RRFServiceIntegration.PlitsPassword, UserName = RRFServiceIntegration.PlitsUserName, Supplychainunitid = RRFServiceIntegration.GetBranchID() }; var branchReq = new GetBranchRRFormRequest { UserName = RRFServiceIntegration.PlitsUserName, Password = RRFServiceIntegration.PlitsPassword, Supplychainunitid = RRFServiceIntegration.GetBranchID() }; var formReq = new GetFormsRequest { Password = RRFServiceIntegration.PlitsPassword, UserName = RRFServiceIntegration.PlitsUserName, Supplychainunitid = RRFServiceIntegration.GetBranchID() }; var forms = client1.GetForms(formReq).GetFormsResult; var formid = forms[0].Id; var periods = client1.GetCurrentReportingPeriod(req).GetCurrentReportingPeriodResult; var period = periods[0].Id; branchReq.Formid = formid; branchReq.Reportingperiodid = period; var chosenCatId = 91;//RRFHelper.GetRrfCategoryId(cboStores.Text); var rrfs = client1.GetBranchRRForm(branchReq).GetBranchRRFormResult; var formCategories = rrfs.First().FormCategories; var chosenCategoryBody = formCategories.First(x => x.Id == chosenCatId); //Hard coding to be removed. var items = chosenCategoryBody.Pharmaceuticals; //Let's just store the items here (May not be required) var user = new User(); user.LoadByPrimaryKey(CurrentContext.LoggedInUser.ID); var order = new HCMIS.Desktop.PLITSTransactionalService.Order { //Id = (int)rrf["Id"], RequestCompletedDate = BLL.DateTimeHelper.ServerDateTime,//Convert.ToDateTime(rrf["DateOfSubmissionEth"]), OrderCompletedBy = user.FullName, RequestVerifiedDate = BLL.DateTimeHelper.ServerDateTime, OrderTypeId = 1, //This needs to be changed to constant class or something. 1 - Regular, 2 - Emergency' SubmittedBy = user.FullName, SubmittedDate = BLL.DateTimeHelper.ServerDateTime, SupplyChainUnitId = Helpers.RRFServiceIntegration.GetBranchID(), OrderStatus = 1,//TODO: hardcoding FormId = formid,//TODO: hardcoding ReportingPeriodId = period //TODO: hardcoding }; // order.OrderTypeId = (int)tblrrf.Rows[i]["RRfTpyeId"]; // Set order properties //order.FormId = rrfForm.Id; //Form.ID? or RRFForm.ID? - doesn't make sense // order.ReportingPeriodId = periods[0].Id; //Asked again here? Because RRFForm already contains this. var details = new Collection<OrderDetail>(); int i = 0; var xx = tblRRF.Rows.Count; foreach (DataRow rrfLine in tblRRF.Rows) { var detail = new PLITSTransactionalService.OrderDetail(); var hcmisItemID = Convert.ToInt32(rrfLine["ID"]); var rrFormPharmaceutical = items.FirstOrDefault(x => x.PharmaceuticalId == Convert.ToInt32(rrfLine["ID"])); if (rrfLine != null && rrFormPharmaceutical!=null) { detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]); //DaysOutOfStock daysOfStockOut = new DaysOutOfStock() { NumberOfDaysOutOfStock = 1 }; //detail.DaysOutOfStocks.Add(daysOfStockOut);//Convert.ToInt32(rrfLine["DaysOutOfStock"]); int eBalance = Convert.ToInt32(rrfLine["SOH"]); detail.EndingBalance = eBalance == 0 ? 1 : eBalance; //To make sure ending balance is not zero. //detail.ItemId = Convert.ToInt32(rrfLine["ID"]); //Needs to come from the Code column of Items table. detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]); detail.QuantityOrdered = Convert.ToInt32(rrfLine["Quantity"]); detail.LossAdjustment = Convert.ToInt32(rrfLine["LossAdj"]); if (rrFormPharmaceutical != null) detail.ItemId = rrFormPharmaceutical.ItemId; else throw new Exception("Item ID Mismatch"); var rdDoc = new ReceiveDoc(); var lossAndAdjustment = new LossAndAdjustment(); rdDoc.GetAllWithQuantityLeft(hcmisItemID, _storeID); lossAndAdjustment.GetLossAdjustmentsForLastRRFPeriod(hcmisItemID, _storeID, periods[0].StartDate, periods[0].EndDate); int receiveDocEntries = rdDoc.RowCount; int disposalEntries = lossAndAdjustment.RowCount; rdDoc.Rewind(); for (var j = 0; j < receiveDocEntries; j++) { var exp = new Expiry { Amount = Convert.ToInt32(rdDoc.QuantityLeft), BatchNo = rdDoc.BatchNo, ExpiryDate = rdDoc.ExpDate }; detail.Expiries.Add(exp); rdDoc.MoveNext(); } lossAndAdjustment.Rewind(); for (var j = 0; j < disposalEntries; j++) { var adj = new Adjustment {Amount = Convert.ToInt32(lossAndAdjustment.Quantity), TypeId = 11, ReasonId = 39}; detail.Adjustments.Add(adj); lossAndAdjustment.MoveNext(); } var stockoutIndexedLists = StockoutIndexBuilder.Builder.GetStockOutHistory(hcmisItemID, _storeID); for (int j = 0; j < stockoutIndexedLists.Count; j++) { var dos = new DaysOutOfStock { NumberOfDaysOutOfStock = stockoutIndexedLists[j].NumberOfDays, StockOutReasonId = 5 }; detail.DaysOutOfStocks.Add(dos); } details.Add(detail); } } order.OrderDetails = details; orders.Add(order); // loop through each record and create order & order details objects return orders; //var user = new User(); //user.LoadByPrimaryKey(NewMainWindow.LoggedInUser.ID); //foreach (DataRow rrf in tblRRF.Rows) //{ // var order = new HCMIS.Desktop.PLITSTransactionalService.Order // { // Id = (int)rrf["Id"], // RequestCompletedDate = DateTime.Now,//Convert.ToDateTime(rrf["DateOfSubmissionEth"]), // OrderCompletedBy = user.FullName, // RequestVerifiedDate = DateTime.Now, // OrderTypeId = 1, //This needs to be changed to constant class or something. 1 - Regular, 2 - Emergency' // SubmittedBy = user.FullName, // SubmittedDate = DateTime.Now, // SupplyChainUnitId = RRFServiceIntegration.BranchID, // OrderStatus = 1, // FormId = formid // }; // // order.OrderTypeId = (int)tblrrf.Rows[i]["RRfTpyeId"]; // // Set order properties // //order.FormId = rrfForm.Id; //Form.ID? or RRFForm.ID? - doesn't make sense // // order.ReportingPeriodId = periods[0].Id; //Asked again here? Because RRFForm already contains this. // var details = new Collection<OrderDetail>(); // foreach (DataRow rrfLine in tblRRF.Rows) // { // var detail = new PLITSTransactionalService.OrderDetail(); // var rrFormPharmaceutical = items.FirstOrDefault(x => x.ItemId == Convert.ToInt32(rrfLine["ID"])); // if (rrfLine != null && rrFormPharmaceutical != null) // //detail.Adjustments[0].Amount = (int)rrfLine["Adjustments"]; // { // detail.BeginningBalance = Convert.ToInt32(rrfLine["BeginingBalance"]); // //detail.DaysOutOfStocks = Convert.ToInt32(rrfLine["DaysOutOfStock"]); // detail.EndingBalance = Convert.ToInt32(rrfLine["SOH"]); // //detail.ItemId = Convert.ToInt32(rrfLine["ID"]); //Needs to come from the Code column of Items table. // detail.QuantityReceived = Convert.ToInt32(rrfLine["Received"]); // detail.QuantityOrdered = Convert.ToInt32(rrfLine["Quantity"]); // detail.LossAdjustment = Convert.ToInt32(rrfLine["LossAdj"]); // if (rrFormPharmaceutical != null) // detail.PharmaceuticalId = rrFormPharmaceutical.PharmaceuticalId; // // detail.PharmaceuticalId = Convert.ToInt32(rrfLine["ItemID"]); // // detail.PharmaceuticalId = pharId; // } // details.Add(detail); // } // order.OrderDetails = details; // orders.Add(order); //} //// loop through each record and create order & order details objects //return orders; }