public static void RecordDiscrepancy(Dictionary <int, decimal> _discrepancyIssueDoc) { foreach (int issueDocID in _discrepancyIssueDoc.Keys) { BLL.IssueDoc issueDoc = new IssueDoc(); issueDoc.LoadByPrimaryKey(issueDocID); issueDoc.NoOfPackIssued = _discrepancyIssueDoc[issueDocID]; issueDoc.Save(); } }
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); } }
private void EditIssue_Load(object sender, EventArgs e) { Stores str = new Stores(); str.LoadAll(); cboStores.DataSource = str.DefaultView; ReceivingUnits rUnit = new ReceivingUnits(); rUnit.GetActiveDispensaries(); cboReceivingUnit.DataSource = rUnit.DefaultView; if (_tranId != 0) { IssueDoc iss = new IssueDoc(); Items itm = new Items(); iss.LoadByPrimaryKey(_tranId); DataTable dtItm = itm.GetItemById(iss.ItemID); string itemName = dtItm.Rows[0]["ItemName"].ToString() + " - " + dtItm.Rows[0]["DosageForm"].ToString() + " - " + dtItm.Rows[0]["Strength"].ToString(); txtRefNo.Text = iss.RefNo; txtBatchNo.Text = iss.BatchNo; try { txtPack.Text = iss.NoOfPack.ToString(); txtQtyPack.Text = iss.QtyPerPack.ToString(); txtPrice.Text = (iss.Cost * iss.QtyPerPack).ToString(); } catch { txtPack.Text = "0"; txtQtyPack.Text = "0"; txtPrice.Text = (iss.Cost * 1).ToString(); } txtQuantity.Text = iss.Quantity.ToString(); DateTime dtDate = Convert.ToDateTime(iss.Date.ToString("MM/dd/yyyy")); txtDate.Text = dtDate.ToShortDateString(); //dtIssDate.Value = DateTime.Now; //dtIssDate.CustomFormat = "MM/dd/yyyy"; //DateTime dtCurrent = Convert.ToDateTime(dtIssDate.Text); //long tic = (DateTime.Now.Ticks - dtCurrent.Ticks); //DateTime dtIssG = dtDate.AddTicks(tic); //dtIssDate.Value = dtIssG; cboStores.SelectedValue = iss.StoreId; cboReceivingUnit.SelectedValue = iss.ReceivingUnitID; txtItemName.Text = itemName; txtReceivedBy.Text = iss.IssuedBy; txtRemark.Text = iss.Remark; } }
/// <summary> /// Needs to be the first function to be called when saving a new receive doc entry. /// </summary> /// <param name="rec"></param> /// <param name="receiptID"></param> /// <param name="dr"></param> private void FillInReceiveDocInformation(ReceiveDoc rec, int receiptID, DataRowView dr) { try { rec.GetColumn("GUID"); } catch { rec.AddColumn("GUID", typeof(string)); //rec.AddColumn("IsDamaged", typeof(bool)); //This is only used if the Check box is used to receive damaged receives (For SRM only) } rec.StoreID = Convert.ToInt32(lkAccounts.EditValue); rec.RefNo = txtRefNo.Text; rec.Remark = txtRemark.Text; rec.ReceivedBy = CurrentContext.LoggedInUserName; DateTime xx = dtRecDate.Value; dtRecDate.CustomFormat = "MM/dd/yyyy"; DateTime dtRec = new DateTime(); rec.Date = ConvertDate.DateConverter(dtRecDate.Text); dtRec = ConvertDate.DateConverter(dtRecDate.Text); rec.EurDate = BLL.DateTimeHelper.ServerDateTime; rec.ItemID = Convert.ToInt32(dr["ID"]); rec.NoOfPack = Convert.ToDecimal(dr["Pack Qty"]); rec.SetColumn("GUID", dr["GUID"].ToString()); rec.IsDamaged = Convert.ToBoolean(dr["IsDamaged"]); if (standardRecType == StandardReceiptType.iGRVOnline) { rec.SetColumn("PricePerPack", dr["Price/Pack"]); rec.SetColumn("Margin", dr["Margin"]); rec.SetColumn("UnitCost", dr["Price/Pack"]); } //TODO: This if is a garbage. Remove if (dr["InvoicedQty"] == DBNull.Value) { rec.InvoicedNoOfPack = rec.NoOfPack; } rec.InvoicedNoOfPack = srm ? Convert.ToDecimal(dr["IssuedQty"]) : Convert.ToDecimal(dr["OriginalInvoicedQty"]); rec.ManufacturerId = Convert.ToInt32(dr["Manufacturer"]); BLL.ItemManufacturer im = new BLL.ItemManufacturer(); im.LoadIMbyLevel(rec.ItemID, rec.ManufacturerId, 0); if (dr["UnitID"] != DBNull.Value) { // if unit has been set, pick the qty per pack from the unit rec.UnitID = Convert.ToInt32(dr["UnitID"]); ItemUnit itemUnit = new ItemUnit(); itemUnit.LoadByPrimaryKey(rec.UnitID); rec.QtyPerPack = itemUnit.QtyPerUnit; } else { rec.QtyPerPack = im.QuantityInBasicUnit; } rec.Quantity = rec.QuantityLeft = rec.NoOfPack * rec.QtyPerPack; try { if ((deliveryNoteType == DeliveryNoteType.NotSet)) { if (!BLL.Settings.HandleGRV && !srm) { rec.PricePerPack = Convert.ToDouble(dr["Price/Pack"]); double pre = (Convert.ToDouble(dr["Price/Pack"]) / 1); //rec.QtyPerPack); rec.Cost = pre; } rec.DeliveryNote = false; } else { rec.DeliveryNote = true; if (deliveryNoteType == DeliveryNoteType.Automatic) { rec.SetColumn("PricePerPack", dr["Price/Pack"]); rec.SetColumn("Margin", dr["Margin"]); rec.SetColumn("UnitCost", dr["Price/Pack"]); } } } catch { // catch the error if the recieve doesn't have cost information // NOTE: this shall never happen. } if (dr["Batch No"] != DBNull.Value) { rec.BatchNo = dr["Batch No"].ToString(); // receivingGrid.Rows[i].Cells[8].Value.ToString(); } if (dr["Expiry Date"] != DBNull.Value) { rec.ExpDate = Convert.ToDateTime(dr["Expiry Date"]); //receivingGrid.Rows[i].Cells[9].Value); } if (!srm) { rec.SupplierID = _supplierID; } else { rec.SupplierID = BLL.Supplier.CONSTANTS.RETURNED_FROM_FACILITY; //TODO: Returned From Supplier: To be removed. This is an unacceptable hack. rec.RefNo = lkSTVInvoiceNo.Text; if (string.IsNullOrEmpty(txtRemark.Text)) { XtraMessageBox.Show( "Please enter the reason for the SRM.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); throw new Exception("Reason not entered for SRM"); } else { rec.Remark = txtRemark.Text; } } rec.ReturnedStock = srm; if (srm && !chkSRMForOldSystemIssues.Checked) { rec.ReturnedFromIssueDocID = int.Parse(dr["IssueDocID"].ToString()); int issueDocID = int.Parse(dr["IssueDocID"].ToString()); BLL.IssueDoc iss = new IssueDoc(); iss.LoadByPrimaryKey(issueDocID); BLL.ReceiveDoc rd = new ReceiveDoc(); rd.LoadByPrimaryKey(iss.RecievDocID); //If it was a delivery note, then the return will not have price information associated with it. // HW-2189 decimal? UnitCost, SellingPrice, Margin; UnitCost = SellingPrice = Margin = null; if (!BLL.Settings.HandleGRV) { if (!iss.IsColumnNull("UnitCost") && iss.IsColumnNull("SellingPrice")) { UnitCost = iss.UnitCost; SellingPrice = iss.SellingPrice; Margin = !iss.IsColumnNull("Margin") ? iss.Margin : 0; } else if (!iss.IsColumnNull("Cost")) { Margin = !rd.IsColumnNull("Margin") ? Convert.ToDecimal(rd.Margin) : 0; SellingPrice = Convert.ToDecimal(iss.Cost / Convert.ToDouble(iss.NoOfPack)); UnitCost = BLL.Settings.IsCenter ? SellingPrice : SellingPrice / Convert.ToDecimal(Margin + 1); } } else { if (!iss.IsColumnNull("UnitCost") && iss.IsColumnNull("SellingPrice") && iss.UnitCost != 0 && iss.SellingPrice != 0) { UnitCost = iss.UnitCost; SellingPrice = iss.SellingPrice; Margin = !iss.IsColumnNull("Margin") ? iss.Margin : 0; } else if (!iss.IsColumnNull("Cost") && iss.Cost != 0) { Margin = !rd.IsColumnNull("Margin") ? Convert.ToDecimal(rd.Margin) : 0; SellingPrice = Convert.ToDecimal(iss.Cost / Convert.ToDouble(iss.NoOfPack)); UnitCost = BLL.Settings.IsCenter ? SellingPrice : SellingPrice / Convert.ToDecimal(Margin + 1); } } if (UnitCost.HasValue) { rec.PricePerPack = Convert.ToDouble(UnitCost); rec.Cost = Convert.ToDouble(UnitCost); rec.UnitCost = UnitCost.Value; } if (SellingPrice.HasValue) { rec.SellingPrice = Convert.ToDouble(SellingPrice); } if (Margin.HasValue) { rec.Margin = Convert.ToDouble(Margin); } if (!rd.IsColumnNull("SupplierID")) rec.SupplierID = rd.SupplierID; } rec.ReceiptID = receiptID; if (BLL.Settings.HandleGRV && !beginningBalance) { rec.RefNo = receiptID.ToString(); } else if (beginningBalance) { rec.RefNo = "BeginningBalance"; } //Needs to be fixed! Garbage string batch = DateTimeHelper.ServerDateTime.Day.ToString() + DateTimeHelper.ServerDateTime.Hour.ToString() + DateTimeHelper.ServerDateTime.Minute.ToString() + rec.ItemID.ToString(); rec.LocalBatchNo = batch; rec.Out = false; rec.IsApproved = false; if (dr["ShortageReasonID"] != DBNull.Value) { rec.ShortageReasonID = Convert.ToInt32(dr["ShortageReasonID"]); } var item = new Item(); item.LoadByPrimaryKey(Convert.ToInt32(dr["id"])); if (dr["ShortageReasonID"] == DBNull.Value && (item.NeedExpiryBatch || rec.ExpDate <= DateTimeHelper.ServerDateTime)) { rec.ShortageReasonID = ShortageReasons.Constants.DAMAGED; } dtRecDate.Value = xx; _receiptID = receiptID; //Assign it to the global variable so it can be used later on. }
private void tpDelete_Click(object sender, EventArgs e) { DataRow dr = gridViewBinCard.GetFocusedDataRow(); if (Convert.ToInt32(dr["Precedance"]) != 3) { XtraMessageBox.Show("You cannot delete this"); return; } if (CurrentContext.LoggedInUser.UserType == UserType.Constants.DISTRIBUTION_MANAGER_WITH_DELETE) { if ( XtraMessageBox.Show( "Are you sure you want to delete this transaction? You will not be able to undo this.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyGeneration.dOOdads.TransactionMgr tranMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { tranMgr.BeginTransaction(); ReceiveDoc rdoc = new ReceiveDoc(); ReceivePallet rp = new ReceivePallet(); IssueDoc idoc = new IssueDoc(); PickListDetail pld = new PickListDetail(); int issueID = Convert.ToInt32(dr["ID"]); //pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"]), // Convert.ToInt32(dr["Quantity"])); idoc.LoadByPrimaryKey(issueID); pld.LoadByPrimaryKey(idoc.PLDetailID); string RefNo = idoc.RefNo; rdoc.LoadByPrimaryKey(idoc.RecievDocID); //if (pld.RowCount == 0) //{ // pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"])); //} rp.LoadByPrimaryKey(pld.ReceivePalletID); PalletLocation pl = new PalletLocation(); pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { pl.LoadByPrimaryKey(pld.PalletLocationID); if (pl.IsColumnNull("PalletID")) { pl.PalletID = rp.PalletID; pl.Save(); } //rp.LoadNonZeroRPByReceiveID(rdoc.ID); } if (rp.RowCount == 0) { XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error"); return; } if (rp.RowCount > 0) { rdoc.QuantityLeft += idoc.Quantity; rp.Balance += idoc.Quantity; pld.QuantityInBU = 0; // are we adding it the pick face? // if so add it to the balance of the pick face also pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { PutawayLocation plocation = new PutawayLocation(rdoc.ItemID); // we don't have a location for this yet, // select a new location //PutawayLocataion pl = new PutawayLocataion(); if (plocation.ShowDialog() == System.Windows.Forms.DialogResult.OK) { pl.LoadByPrimaryKey(plocation.PalletLocationID); if (pl.RowCount > 0) { pl.PalletID = rp.PalletID; pl.Save(); } } } if (pl.RowCount > 0) { PickFace pf = new PickFace(); pf.LoadByPalletLocation(pl.ID); if (pf.RowCount > 0) { pf.Balance += Convert.ToInt32(idoc.Quantity); pf.Save(); } IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId); idoc.MarkAsDeleted(); rdoc.Save(); rp.Save(); idoc.Save(); // now refresh the window XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); tranMgr.CommitTransaction(); //TODO: refresh the list // gridViewReferences_FocusedRowChanged(null, null); } } else { XtraMessageBox.Show( "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.", "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error); tranMgr.RollbackTransaction(); } } catch { XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); tranMgr.RollbackTransaction(); } } } else { XtraMessageBox.Show( "You cannot delete this transaction because you don't have previlage. Please contact the administrator if you thing this is an error.", "Delete is not allowed"); } }
/// <summary> /// Fix For Delivery Note When Converting Do not use under any other situation /// </summary> /// <param name="issueDocID"></param> /// <param name="picklistID"></param> /// <returns></returns> public PickListDetail FixDeliveryNoteCostReceiveDoc(int issueDocID, int picklistID) { IssueDoc issueDoc = new IssueDoc(); issueDoc.LoadByPrimaryKey(issueDocID); PickListDetail pickList = new PickListDetail(); pickList.LoadByPrimaryKey(picklistID); //safety first if (issueDoc.RecievDocID != pickList.ReceiveDocID) { Item item = new Item(); item.LoadByPrimaryKey(picklistID); throw new Exception(String.Format("PicklistDetail vs IssueDoc Inconsistancy for Item {0}", item.FullItemName)); } // now we are sure we have one ReceiveDocID ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(pickList.ReceiveDocID); ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); receiveDocConfirmation.LoadByReceiveDocID(receiveDoc.ID); //Check if it has been Printed and that Selling Price and Cost is set if (receiveDocConfirmation.ReceiptConfirmationStatusID == ReceiptConfirmationStatus.Constants.GRV_PRINTED) { double unitPrice, unitCost, margin; if (Settings.IsCenter == true && !receiveDoc.IsColumnNull("Cost") && receiveDoc.Cost != 0) { unitPrice = Math.Round(receiveDoc.Cost, 2); unitCost = Math.Round(receiveDoc.Cost, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else if (!receiveDoc.IsColumnNull("SellingPrice") && receiveDoc.SellingPrice != 0) { unitPrice = Math.Round(receiveDoc.SellingPrice, 2); unitCost = Math.Round(receiveDoc.SellingPrice, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("Price Not set For item: {0}", item.FullItemName)); } pickList.UnitPrice = unitPrice; pickList.Cost = Convert.ToDouble(pickList.Packs) * unitPrice; issueDoc.SellingPrice = Convert.ToDecimal(unitPrice); issueDoc.Cost = Convert.ToDouble(issueDoc.NoOfPack) * unitPrice; issueDoc.UnitCost = Convert.ToDecimal(unitCost); issueDoc.Margin = Convert.ToDecimal(margin); pickList.Save(); issueDoc.Save(); } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("GRV/IGRV Not Printed For Item: {0}", item.FullItemName)); } return pickList; }
private void PrintReceiptConfirmation(string referenceNumber, int? reprintOfReceiptConfirmationPrintoutID) { var rc = new ReceiptConfirmationPrintout(); var srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(CurrentContext.LoggedInUserName); int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]); var receiveDoc = new ReceiveDoc(); receiveDoc.LoadByReceiptID(ReceiptID); ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID); srmPrintout.BranchName.Text = GeneralInfo.Current.HospitalName; rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 3, null, reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current); srmPrintout.DataSource = rc.DefaultView.ToTable(); var rUnit = new Institution(); var idoc = new IssueDoc(); if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID")) { idoc.LoadByPrimaryKey(receiveDoc.ReturnedFromIssueDocID); rUnit.LoadByPrimaryKey(idoc.ReceivingUnitID); } else { var po = new PO(); po.LoadByReceiptID(receiveDoc.ReceiptID); rUnit.LoadByPrimaryKey(int.Parse(po.RefNo)); } srmPrintout.xrFromValue.Text = rUnit.Name; srmPrintout.xrWoredaValue.Text = rUnit.WoredaText; srmPrintout.xrRegionValue.Text = rUnit.Region; srmPrintout.xrZoneValue.Text = rUnit.ZoneText; if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID")) { var stvLog = new BLL.Issue(); stvLog.LoadByPrimaryKey(idoc.STVID); srmPrintout.xrIssueDateValue.Text = idoc.Date.ToString("M/d/yyyy"); var activity = new Activity(); activity.LoadByPrimaryKey(idoc.StoreId); srmPrintout.xrAccountName.Text = activity.FullActivityName; var rct = new BLL.Receipt(); rct.LoadByPrimaryKey(ReceiptID); var rctInvoice = new ReceiptInvoice(); rctInvoice.LoadByPrimaryKey(rct.ReceiptInvoiceID); srmPrintout.xrSTVNoValue.Text = rctInvoice.STVOrInvoiceNo; } else { var activity = new Activity(); activity.LoadByPrimaryKey(receiveDoc.StoreID); srmPrintout.xrAccountName.Text = activity.FullActivityName; srmPrintout.xrSTVNoValue.Text = receiveDoc.RefNo; } var dtDate = new DateTimePickerEx(); dtDate.Value = receiveDoc.EurDate; srmPrintout.Date.Text = dtDate.Text; if (srmPrintout.PrintDialog() != DialogResult.OK) { throw new Exception("Print cancelled by user!"); } //Successfully printed //Release Product var GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); GRV.ReleaseForIssue(); String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString(); var recDoc = new ReceiveDoc(); recDoc.LoadByReferenceNo(reference); recDoc.ConfirmGRVPrinted(CurrentContext.UserId); BLL.Receipt receiptStatus = new BLL.Receipt(); receiptStatus.LoadByPrimaryKey(ReceiptID); receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed"); BindFormContents(); }
public static void DeleteIssueDoc(int issueID) { MyGeneration.dOOdads.TransactionMgr tranMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { tranMgr.BeginTransaction(); var pld = new PickListDetail(); var rdoc = new ReceiveDoc(); var rp = new ReceivePallet(); var idoc = new IssueDoc(); idoc.LoadByPrimaryKey(issueID); pld.LoadByPrimaryKey(idoc.PLDetailID); rdoc.LoadByPrimaryKey(idoc.RecievDocID); rp.LoadByPrimaryKey(pld.ReceivePalletID); var pl = new PalletLocation(); pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { pl.LoadByPrimaryKey(pld.PalletLocationID); if (pl.IsColumnNull("PalletID")) { pl.PalletID = rp.PalletID; pl.Save(); } } if (rp.RowCount == 0) { XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error"); return; } if (rp.RowCount > 0) { // in error cases this could lead to a number greater than the received quantity // instead of being an error, it should just delete the respective issue and // adjust the remaining quantity to the received quantity. if (rdoc.QuantityLeft + idoc.Quantity > rdoc.Quantity) { rdoc.QuantityLeft = rp.Balance = rdoc.Quantity; } else { rdoc.QuantityLeft += idoc.Quantity; rp.Balance += idoc.Quantity; } //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); // are we adding it the pick face? // if so add it to the balance of the pick face also pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { var plocation = new PutawayLocation(rdoc.ItemID); // we don't have a location for this yet, // select a new location //PutawayLocataion pl = new PutawayLocataion(); if (plocation.ShowDialog() == DialogResult.OK) { pl.LoadByPrimaryKey(plocation.PalletLocationID); if (pl.RowCount > 0) { pl.PalletID = rp.PalletID; pl.Save(); } } } if (pl.RowCount > 0) { var pf = new PickFace(); pf.LoadByPalletLocation(pl.ID); if (pf.RowCount > 0) { pf.Balance += Convert.ToInt32(idoc.Quantity); pf.Save(); } IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId); idoc.MarkAsDeleted(); rdoc.Save(); rp.Save(); idoc.Save(); pld.Save(); // now refresh the window XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); tranMgr.CommitTransaction(); } } else { XtraMessageBox.Show( "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.", "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error); tranMgr.RollbackTransaction(); } } catch { XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); tranMgr.RollbackTransaction(); } }
private void unconfirmedMenuClicked_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { DataRow dataRow = gridUnconfirmedView.GetFocusedDataRow(); if (dataRow != null) { if (e.ClickedItem.Text == "Delete") { if (DialogResult.Yes == XtraMessageBox.Show("Are you sure you would like to delete this?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { DeleteIssueDoc(Convert.ToInt32(dataRow["ID"])); // Refresh it gridViewReferences_FocusedRowChanged(null, null); //XtraMessageBox.Show("Issue has been deleted"); } } else if (e.ClickedItem.Text == "Confirm") { IssueDoc doc = new IssueDoc(); doc.LoadByPrimaryKey(Convert.ToInt32(dataRow["ID"])); // do some validations if (doc.IsColumnNull("STVID")) { doc.STVID = _stvLogIdChosen.Value; doc.Save(); } // refresh XtraMessageBox.Show("You have confirmed the STV", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); gridViewReferences_FocusedRowChanged(null, null); } } }
/* private void GenerateBinCard() { ReceiveDoc rec = new ReceiveDoc(); IssueDoc iss = new IssueDoc(); Disposal dis = new Disposal(); DisposalReasons res = new DisposalReasons(); Balance bal = new Balance(); GeneralInfo info = new GeneralInfo(); YearEnd yEnd = new YearEnd(); Items itm = new Items(); info.LoadAll(); year = Convert.ToInt32(cboYear.SelectedItem); DataTable dtRec = rec.GetAllTransaction(itemId,storeId,dtCurrent.Month,year); DataTable dtIss = iss.GetTransactionByItemId(storeId, itemId, year); DataTable dtDis = dis.GetTransactionByItemId(storeId, itemId, year); Int64[] cStockout = { 0, 0, 0 }; Int64[] cOverStock = { 0, 0, 0 }; Int64[] cNearStockOut = { 0, 0, 0 }; Int64[] cBelowMin = { 0, 0, 0 }; //DateTime dtThree = dtCurrent.AddMonths(3); DataTable dtbin = new DataTable(); string[] col = { "Date", "Ref. No", "Receive", "Issue", "Unit Price", "Balance", "Batch No", "Expiry Date","To / From"}; foreach (string str in col) { dtbin.Columns.Add(str); } int i = 0; Int64 bBalance = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(dtDate.Text); bBalance = yEnd.GetBBalance(year, storeId, itemId,dtCurrent.Month); Int64 balanceAmount = bBalance; Int64 mincon = 0; Int64 maxcon = 0; double eopcon = 0; DateTime dtT = new DateTime(); string balanceAm = ""; txtBBalance.Text = bBalance.ToString(); string ddDate = ""; string batNo = ""; foreach (DataRow dvRec in dtRec.Rows) { i++; if (Convert.ToInt32(dvRec["Transact"]) == 1) { rec.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); balanceAmount = balanceAmount + Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(rec.ItemID); if (itm.NeedExpiryBatch) { ddDate = rec.ExpDate.ToString("MMM dd,yyyy"); batNo = rec.BatchNo; } Supplier sup = new Supplier(); sup.LoadByPrimaryKey(rec.SupplierID); object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), "", Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, sup.CompanyName}; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); //int monb = (dtT.Month < 11) ? dtT.Month + 2 : ((dtT.Month == 11) ? 1 : 2); //int yer = (dtT.Month < 11) ? dtT.Year : dtT.Year - 1; Int64 bBal = bal.GetSOH(itemId, storeId, dtT.Month, dtT.Year); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } }else if(Convert.ToInt32(dvRec["Transact"]) == 0) { //DateTime dteIss = Convert.ToDateTime(drIss["Date"]); //DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); //DateTime dTomorow = new DateTime(dtCurrent.Year, dtCurrent.Month, dtCurrent.Day + 1); //DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : dTomorow; iss.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); try { rec.LoadByPrimaryKey(iss.RecievDocID); } catch { rec.GetTransactionByBatch(itemId, dvRec["BatchNo"].ToString(), storeId); } ReceivingUnits recUnit = new ReceivingUnits(); recUnit.LoadByPrimaryKey(iss.ReceivingUnitID); string issuedTo = recUnit.Name; balanceAmount = balanceAmount - Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(iss.ItemID); if (itm.NeedExpiryBatch) { ddDate = ((rec.RowCount > 0) ? rec.ExpDate.ToString("MMM dd,yyyy") : ""); ; batNo = dvRec["BatchNo"].ToString(); //rec.BatchNo; } else { ddDate = ""; batNo = ""; } object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], "", Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm,batNo, ddDate,issuedTo}; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); //int monb1 = (dtT.Month < 11) ? dtT.Month + 2 : ((dtT.Month == 11) ? 1 : 2); //int yer1 = (dtT.Month < 11) ? dtT.Year : dtT.Year - 1; Int64 bBal = bal.GetSOH(itemId, storeId, dtT.Month, dtT.Year); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } } foreach (DataRow drDis in dtDis.Rows) { DateTime dteDis = Convert.ToDateTime(drDis["Date"]); DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); res.LoadByPrimaryKey(Convert.ToInt32(drDis["ReasonId"])); rec.GetTransactionByBatch(itemId,drDis["BatchNo"].ToString(),storeId); DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : dtCurrent; if ((dteRec <= dteDis) && (dteDis < dteNextRec)) { if (Convert.ToBoolean(drDis["Losses"])) { balanceAmount = balanceAmount - Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], "", Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason}; dtbin.Rows.Add(objIss); } else { balanceAmount = balanceAmount + Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss2 = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), "", Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason}; dtbin.Rows.Add(objIss2); } dtT = Convert.ToDateTime(dvRec["Date"]); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } } } } transactionGrid.DataSource = dtbin; //Stock Out lblThreeStockout.Text = cStockout[0].ToString(); lblSixStockOut.Text = (cStockout[0] + cStockout[1]).ToString(); lblTwelveStockOut.Text = (cStockout[0] + cStockout[1] + cStockout[2]).ToString(); //Over Stock lblThreeOverStock.Text = cOverStock[0].ToString(); lblSixOverStock.Text = (cOverStock[0] + cOverStock[1]).ToString(); lblTwelveOverStock.Text = (cOverStock[0] + cOverStock[1] + cOverStock[2]).ToString(); //Near eop lblThreeNearStock.Text = cNearStockOut[0].ToString(); lblSixNearStock.Text = (cNearStockOut[0] + cNearStockOut[1]).ToString(); lblTwelveNear.Text = (cNearStockOut[0] + cNearStockOut[1] + cNearStockOut[2]).ToString(); //Below Min lblThreeBelowMin.Text = cBelowMin[0].ToString(); lblSixBelowMin.Text = (cBelowMin[0] + cBelowMin[1]).ToString(); lblTwelveBelowMin.Text = (cBelowMin[0] + cBelowMin[1] + cBelowMin[2]).ToString(); } */ /// <summary> /// Generates the bin card transaction /// </summary> private void GenerateBinCard() { #region NewCode ////Get the beginning balance. //Int64 begBalance = 0; //YearEnd yearEnd = new YearEnd(); //begBalance = yearEnd.GetBeginningBalance(_storeId, _itemId); //txtBBalance.Text = begBalance.ToString(); ////Get the bin card. //Balance balance = new Balance(); //gridItemsList.DataSource = balance.GetBinCard(_storeId, _itemId); //return; #endregion #region Old Code ReceiveDoc rec = new ReceiveDoc(); IssueDoc iss = new IssueDoc(); Disposal dis = new Disposal(); DisposalReasons res = new DisposalReasons(); Balance bal = new Balance(); GeneralInfo info = new GeneralInfo(); YearEnd yEnd = new YearEnd(); Items itm = new Items(); info.LoadAll(); if (cboFiscalYear.SelectedItem == null) PopulateBinCardYearCombo(); //_year = Convert.ToInt32(cboFiscalYear.SelectedItem); _year = Convert.ToInt32(cboYear.SelectedItem); int yer = _year; //int mth = (_year > _dtCurrent.Year) ? _dtCurrent.Month : 10; int mth = _dtCurrent.Month; EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(_year, 1, 1); //if (_dtCurrent.Month < 11) //{ // yer = _year; //} //else //{ // yer = _year - 1; //} //DataTable dtRec = rec.GetAllTransaction(_itemId, _storeId, ethioDate.Month,ethioDate.Year); DataTable dtRec = rec.GetAllTransaction(_itemId, _storeId, ethioDate.FiscalYear); DataTable dtIss = iss.GetTransactionByItemId(_storeId, _itemId, ethioDate.FiscalYear); DataTable dtDis = dis.GetTransactionByItemId(_storeId, _itemId, ethioDate.FiscalYear); Int64[] cStockout = { 0, 0, 0 }; Int64[] cOverStock = { 0, 0, 0 }; Int64[] cNearStockOut = { 0, 0, 0 }; Int64[] cBelowMin = { 0, 0, 0 }; //DateTime dtThree = dtCurrent.AddMonths(3); DataTable dtbin = new DataTable(); string[] col = { "Date", "RefNo", "Receive", "Issue", "Unit Price", "Balance", "Batch No", "Expiry Date", "ToFrom" }; foreach (string str in col) { dtbin.Columns.Add(str); } int i = 0; Int64 bBalance = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCurrent = ConvertDate.DateConverter(dtDate.Text); //bBalance = yEnd.GetBBalance(_year, _storeId, _itemId, _dtCurrent.Month); bBalance = yEnd.GetBBalance(_year, _storeId, _itemId); Int64 balanceAmount = bBalance; DateTime dtT = new DateTime(); string balanceAm = ""; string ddDate = ""; string batNo = ""; foreach (DataRow dvRec in dtRec.Rows) { i++; if (Convert.ToInt32(dvRec["Transact"]) == 1) { rec.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); if (dvRec["Quantity"] == DBNull.Value) { dvRec["Quantity"] = 0; } balanceAmount = balanceAmount + Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(rec.ItemID); if (itm.NeedExpiryBatch) { if (!rec.IsColumnNull("ExpDate")) { ddDate = rec.ExpDate.ToString("MMM dd,yyyy"); batNo = rec.BatchNo; } } Supplier sup = new Supplier(); sup.LoadByPrimaryKey(rec.SupplierID); object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), "", Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, sup.CompanyName }; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); } else if (Convert.ToInt32(dvRec["Transact"]) == 0) { iss.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); try { rec.LoadByPrimaryKey(iss.RecievDocID); } catch { rec.GetTransactionByBatch(_itemId, dvRec["BatchNo"].ToString(), _storeId); } ReceivingUnits recUnit = new ReceivingUnits(); recUnit.LoadByPrimaryKey(iss.ReceivingUnitID); string issuedTo = recUnit.Name; balanceAmount = balanceAmount - Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(iss.ItemID); if (itm.NeedExpiryBatch) { ddDate = ((rec.RowCount > 0) ? rec.ExpDate.ToString("MMM dd,yyyy") : ""); ; batNo = dvRec["BatchNo"].ToString(); //rec.BatchNo; } else { ddDate = ""; batNo = ""; } object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], "", Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, issuedTo }; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); } foreach (DataRow drDis in dtDis.Rows) { DateTime dteDis = Convert.ToDateTime(drDis["Date"]); DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); res.LoadByPrimaryKey(Convert.ToInt32(drDis["ReasonId"])); rec.GetTransactionByBatch(_itemId, drDis["BatchNo"].ToString(), _storeId); DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : _dtCurrent; if ((dteRec <= dteDis) && (dteDis < dteNextRec)) { if (Convert.ToBoolean(drDis["Losses"])) { balanceAmount = balanceAmount - Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; if (rec.RowCount > 0) { object[] objIss = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], "", Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason }; dtbin.Rows.Add(objIss); } } else { balanceAmount = balanceAmount + Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss2 = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), "", Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason }; dtbin.Rows.Add(objIss2); } dtT = Convert.ToDateTime(dvRec["Date"]); } } } gridItemsList.DataSource = dtbin; #endregion }
public void DeleteAnIssue(int issueDociD) { ReceiveDoc rdoc = new ReceiveDoc(); ReceivePallet rp = new ReceivePallet(); IssueDoc idoc = new IssueDoc(); idoc.LoadByPrimaryKey(issueDociD); if (idoc.IsThereSRM) { throw new Exception("There is an SRM for this issue. You can't void it."); } PickListDetail pld = new PickListDetail(); //pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID, idoc.NoOfPack); pld.LoadByPrimaryKey(idoc.PLDetailID); string RefNo = idoc.RefNo; rdoc.LoadByPrimaryKey(idoc.RecievDocID); //if (pld.RowCount == 0) //{ // pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID); //} rp.LoadByReceiveDocID(idoc.RecievDocID); PalletLocation pl = new PalletLocation(); pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { pl.LoadByPrimaryKey(pld.PalletLocationID); if (pl.IsColumnNull("PalletID")) { pl.PalletID = rp.PalletID; pl.Save(); } } if (rp.RowCount == 0) { XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error"); return; } if (rp.RowCount > 0) { rdoc.QuantityLeft += idoc.Quantity; rp.Balance += idoc.Quantity; //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); // are we adding it the pick face? // if so add it to the balance of the pick face also pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { PutawayLocation plocation = new PutawayLocation(rdoc.ItemID); // we don't have a location for this yet, // select a new location //PutawayLocataion pl = new PutawayLocataion(); if (plocation.ShowDialog() == System.Windows.Forms.DialogResult.OK) { pl.LoadByPrimaryKey(plocation.PalletLocationID); if (pl.RowCount > 0) { pl.PalletID = rp.PalletID; pl.Save(); } } } if (pl.RowCount > 0) { PickFace pf = new PickFace(); pf.LoadByPalletLocation(pl.ID); if (pf.RowCount > 0) { pf.Balance += Convert.ToInt32(idoc.Quantity); pf.Save(); } IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId); idoc.MarkAsDeleted(); rdoc.Save(); rp.Save(); idoc.Save(); pld.Save(); } else { XtraMessageBox.Show( "This delete is not successful because a free pick face location was not selected. please select a free location and try again.", "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { var us = new User(); var userID = MainWindow.LoggedinId; us.LoadByPrimaryKey(userID); DataRow dr = gridView1.GetFocusedDataRow(); if (dr == null) return; int tranId = Convert.ToInt32(dr["ID"]); var rec = new ReceiveDoc(); var iss = new IssueDoc(); iss.LoadByPrimaryKey(tranId); string batchNo = iss.BatchNo; try { if (iss.RecievDocID.ToString() != "") rec.LoadByPrimaryKey(iss.RecievDocID); else rec.GetTransactionByBatch(iss.ItemID, iss.BatchNo, iss.StoreId); } catch { rec.GetTransactionByBatch(iss.ItemID, iss.BatchNo, iss.StoreId); } if ( batchNo != rec.BatchNo && batchNo !=string.Empty) { XtraMessageBox.Show("Unable to Delete, This Transaction has been processed. Try Loss and Adjustment.", "Unable to Delete", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else if (batchNo == string.Empty || batchNo ==rec.BatchNo) { if (XtraMessageBox.Show("Are You Sure, You want to delete this Transaction? You will not be able to restore this data.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { rec.QuantityLeft = rec.QuantityLeft + iss.Quantity; if (rec.QuantityLeft > 0) rec.Out = false; rec.Save(); AddIssueLodDelete(iss); iss.MarkAsDeleted(); iss.Save(); DataTable dtRec = iss.GetAllTransaction(Convert.ToInt32(cboStores.EditValue)); gridIssues.DataSource = dtRec; } } }
/// <summary> /// Fix For Delivery Note When Converting Do not use under any other situation /// </summary> /// <param name="issueDocID"></param> /// <param name="picklistID"></param> /// <returns></returns> public PickListDetail FixDeliveryNoteCostReceiveDoc(int issueDocID, int picklistID) { IssueDoc issueDoc = new IssueDoc(); issueDoc.LoadByPrimaryKey(issueDocID); PickListDetail pickList = new PickListDetail(); pickList.LoadByPrimaryKey(picklistID); //safety first if (issueDoc.RecievDocID != pickList.ReceiveDocID) { Item item = new Item(); item.LoadByPrimaryKey(picklistID); throw new Exception(String.Format("PicklistDetail vs IssueDoc Inconsistancy for Item {0}", item.FullItemName)); } // now we are sure we have one ReceiveDocID ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(pickList.ReceiveDocID); ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); receiveDocConfirmation.LoadByReceiveDocID(receiveDoc.ID); //Check if it has been Printed and that Selling Price and Cost is set if (receiveDocConfirmation.ReceiptConfirmationStatusID == ReceiptConfirmationStatus.Constants.GRV_PRINTED) { double unitPrice, unitCost, margin; if (Settings.IsCenter == true && !receiveDoc.IsColumnNull("Cost") && receiveDoc.Cost != 0) { unitPrice = Math.Round(receiveDoc.Cost, 2); unitCost = Math.Round(receiveDoc.Cost, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else if (!receiveDoc.IsColumnNull("SellingPrice") && receiveDoc.SellingPrice != 0) { unitPrice = Math.Round(receiveDoc.SellingPrice, 2); unitCost = Math.Round(receiveDoc.SellingPrice, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("Price Not set For item: {0}", item.FullItemName)); } pickList.UnitPrice = unitPrice; pickList.Cost = Convert.ToDouble(pickList.Packs) * unitPrice; issueDoc.SellingPrice = Convert.ToDecimal(unitPrice); issueDoc.Cost = Convert.ToDouble(issueDoc.NoOfPack) * unitPrice; issueDoc.UnitCost = Convert.ToDecimal(unitCost); issueDoc.Margin = Convert.ToDecimal(margin); pickList.Save(); issueDoc.Save(); } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("GRV/IGRV Not Printed For Item: {0}", item.FullItemName)); } return(pickList); }