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 btnUpdate_Click(object sender, EventArgs e) { var isd = new IssueDoc(); DataTable dtbl = isd.GetTransactionByRefNo(_refno); if (isd.RowCount > 0) { foreach (DataRow datarow in dtbl.Rows) { datarow["RefNo"] = txtRefNo.Text; datarow["Date"] = txtDate.Text; } isd.Save(); Close(); XtraMessageBox.Show("Refrence No and Date is successfully updated", "Success"); } else { XtraMessageBox.Show("There is no refrence no to edit"); return; } this.Close(); }
/// <summary> /// Saves the STVI dby pick list details. /// </summary> /// <param name="plDetailIDs">The pl detail I ds.</param> /// <param name="stvID">The STV ID.</param> private static void SaveSTVIDbyPickListDetails(string plDetailIDs, int stvID) { IssueDoc iDoc = new IssueDoc(); iDoc.LoadByIDs(plDetailIDs); while (!iDoc.EOF) { iDoc.STVID = stvID; iDoc.Save(); iDoc.MoveNext(); } }
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; }
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 btnSave_Click(object sender, EventArgs e) { var transfer = new Transfer(); var newreceiveDoc = new ReceiveDoc(); var receiveDoc = new ReceiveDoc(); var issuedoc = new IssueDoc(); var valid = ValidateFields(); if (valid == "true") { if (XtraMessageBox.Show("Are you sure you want to save this transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try{ var dtRecGrid = (DataTable)receivingGrid.DataSource; for (int i = 0; i < dtRecGrid.Rows.Count; i++) { transfer.AddNew(); var receiveid = Convert.ToInt32(dtRecGrid.Rows[i]["RecID"]); transfer.ItemID = _itemID = Convert.ToInt32(dtRecGrid.Rows[i]["ID"]); transfer.RecID = receiveid; transfer.BatchNo = dtRecGrid.Rows[i]["Batch No"].ToString(); transfer.FromStoreID = Convert.ToInt32(lkFromStore.EditValue); transfer.ToStoreID = Convert.ToInt32(lkToStore.EditValue); transfer.Quantity = Convert.ToInt64(dtRecGrid.Rows[i]["Qty To Transfer"]); transfer.RefNo = txtRefNo.Text; transfer.UnitID = VisibilitySetting.HandleUnits == 1 ? 0 : Convert.ToInt32(dtRecGrid.Rows[i]["UnitID"]); DateTime xx = dtRecDate.Value; dtRecDate.CustomFormat = "MM/dd/yyyy"; new DateTime(); transfer.Date = ConvertDate.DateConverter(dtRecDate.Text); ConvertDate.DateConverter(dtRecDate.Text); dtRecDate.IsGregorianCurrentCalendar = true; transfer.EurDate = dtRecDate.Value; dtRecDate.IsGregorianCurrentCalendar = false; transfer.TransferReason = txtTransferReason.Text; transfer.ApprovedBy = txtApprovedBy.Text; transfer.TransferRequestedBy = txtRequestedBy.Text; transfer.Save(); transfer.GetTransfered(receiveid, _itemID, Convert.ToInt32(lkFromStore.EditValue)); issuedoc.AddNew(); issuedoc.StoreId = transfer.FromStoreID; issuedoc.ItemID = transfer.ItemID; issuedoc.Quantity = transfer.Quantity; issuedoc.Date = transfer.Date; issuedoc.BatchNo = transfer.BatchNo; issuedoc.UnitID = transfer.UnitID; issuedoc.RecievDocID = transfer.RecID; issuedoc.IsTransfer = true; issuedoc.RefNo = transfer.RefNo; var allstores = new Stores(); allstores.LoadByPrimaryKey(transfer.ToStoreID); issuedoc.ReceivingUnitID = (int) allstores.GetColumn("ReceivingUnitID"); issuedoc.Save(); receiveDoc.GetReceivedItems(receiveid,_itemID, Convert.ToInt32(lkFromStore.EditValue)); receiveDoc.QuantityLeft = receiveDoc.QuantityLeft - transfer.Quantity; newreceiveDoc.AddNew(); newreceiveDoc.StoreID = transfer.ToStoreID; newreceiveDoc.RefNo = transfer.RefNo; newreceiveDoc.BatchNo = transfer.BatchNo; newreceiveDoc.ItemID = transfer.ItemID; newreceiveDoc.Quantity = transfer.Quantity; newreceiveDoc.QuantityLeft = transfer.Quantity; newreceiveDoc.NoOfPack = Convert.ToInt32(transfer.Quantity) / receiveDoc.QtyPerPack; newreceiveDoc.QtyPerPack = receiveDoc.QtyPerPack; newreceiveDoc.Cost = receiveDoc.Cost; newreceiveDoc.Date = transfer.Date; newreceiveDoc.UnitID = transfer.UnitID; newreceiveDoc.Out = false; newreceiveDoc.ReceivedBy = transfer.ApprovedBy; newreceiveDoc.ExpDate = receiveDoc.ExpDate; allstores.LoadByPrimaryKey(transfer.FromStoreID); newreceiveDoc.SupplierID = (int) allstores.GetColumn("SupplierID"); newreceiveDoc.BoxLevel = 1; newreceiveDoc.Save(); receiveDoc.Save(); } XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ResetFields(); } catch (Exception exp) { XtraMessageBox.Show(exp.InnerException.Message ,"Error"); } } } else { XtraMessageBox.Show(valid, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void btnConfirm_Click(object sender, EventArgs e) { var confirmedItemsQuantity = new Dictionary<int, long>(); var confirmedItems = new List<int>(); var valid = ValidateFields(); if (valid == "true") { if (XtraMessageBox.Show("Are You Sure, You Want To Save This Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var issDoc = new IssueDoc(); var recDoc = new ReceiveDoc(); DataTable dtConfirm; long currentSOH = 0; var storeId = 0; var itemId = 0; using (dtConfirm = (DataTable)gridConfirmation.DataSource) { for (int i = 0; i < dtConfirm.Rows.Count; i++) { var receivedocid = Convert.ToInt32(dtConfirm.Rows[i]["RecId"]); issDoc.GetDULastIssue(Convert.ToInt32(dtConfirm.Rows[i]["ItemID"]), Convert.ToInt32(cboReceivingUnits.EditValue)); confirmedItems.Add(Convert.ToInt32(dtConfirm.Rows[i]["ItemID"])); if (issDoc.RowCount > 0) { //issDoc.DUSOH = ((dtConfirmation.Rows[i]["DUSOH"] != null) ? Convert.ToInt64(dtConfirmation.Rows[i]["DUSOH"]) : 0); //issDoc.Save(); } //Saving the issue issDoc.AddNew(); issDoc.StoreId = Convert.ToInt32(cboStores.EditValue); issDoc.RefNo = txtRefNo.Text.Trim(); issDoc.ReceivingUnitID = Convert.ToInt32(cboReceivingUnits.EditValue); DateTime xx = dtIssueDate.Value; dtIssueDate.CustomFormat = "MM/dd/yyyy"; DateTime dtCurrent = ConvertDate.DateConverter(dtIssueDate.Text); issDoc.Date = dtCurrent; dtIssueDate.IsGregorianCurrentCalendar = true; issDoc.EurDate = dtIssueDate.Value; dtIssueDate.IsGregorianCurrentCalendar = false; issDoc.RecievDocID =Convert.ToInt32(dtConfirm.Rows[i]["RecId"]); // Used to have 8 as an index recDoc.LoadByPrimaryKey(receivedocid); issDoc.IsApproved = true; issDoc.IsTransfer = false; issDoc.Remark = txtRemark.Text; issDoc.RecipientName = txtRecipientName.Text; issDoc.IssuedBy = txtIssuedBy.Text; issDoc.DUSOH = Convert.ToInt32(dtConfirm.Rows[i]["DUSOH"]); issDoc.ItemID = Convert.ToInt32(dtConfirm.Rows[i]["ItemId"]); issDoc.Quantity = Convert.ToInt64(dtConfirm.Rows[i]["Quantity"]); issDoc.NoOfPack = Convert.ToInt32(dtConfirm.Rows[i]["No Of Pack"]); issDoc.QtyPerPack = Convert.ToInt32(dtConfirm.Rows[i]["Qty Per Pack"]); switch (VisibilitySetting.HandleUnits) { case 1: issDoc.UnitID = 0; break; case 2: issDoc.UnitID = Convert.ToInt32(dtConfirm.Rows[i]["UnitID"]); break; default: issDoc.UnitID = Convert.ToInt32(dtConfirm.Rows[i]["UnitID"]); break; } issDoc.BatchNo = dtConfirm.Rows[i]["BatchNo"].ToString(); issDoc.Cost = Convert.ToDouble(dtConfirm.Rows[i]["Unit Price"]); issDoc.RecomendedQty = Convert.ToInt32(dtConfirm.Rows[i]["DURecomended"]);// ((recQty > 0) ? Convert.ToInt64(recQty) : 0); //End DU issDoc.Save(); //updating the receiving doc recDoc.LoadByPrimaryKey(Convert.ToInt32(dtConfirm.Rows[i]["RecId"])); //this line calculates the current SOH recDoc.QuantityLeft = recDoc.QuantityLeft - issDoc.Quantity; currentSOH = currentSOH + recDoc.QuantityLeft; itemId = Convert.ToInt32(dtConfirm.Rows[i]["ItemId"]); var unitId = Convert.ToInt32(dtConfirm.Rows[i]["UnitID"]); if (recDoc.QuantityLeft != 0) recDoc.Out = false; else recDoc.Out = true; if (confirmedItemsQuantity.ContainsKey(itemId)) confirmedItemsQuantity[itemId] += recDoc.QuantityLeft; else { confirmedItemsQuantity.Add(itemId, recDoc.QuantityLeft); } recDoc.Save(); storeId = Convert.ToInt32(cboStores.EditValue); //Log Activity dtIssueDate.Value = xx; Builder.RefreshAMCValues(storeId, confirmedItemsQuantity,unitId); } //save stockout information for the current item in current store //if current SOH after this issue is 0 if (currentSOH == 0) { StockoutLog stockoutLog = new StockoutLog(); stockoutLog.AddNew(); stockoutLog.StoreID = storeId; stockoutLog.ItemID = itemId; stockoutLog.StartDate = DateTime.Today; stockoutLog.Save(); } } XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { XtraMessageBox.Show(valid, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop); } xpButton2_Click(sender, e); issueGrid.DataSource = null; issueGridView.RefreshData(); RefreshItems(); }
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); } } }
/// <summary> /// Saves the whole transaction for /// </summary> /// <param name="orderID">The order ID.</param> /// <param name="dvOutstandingPickList">The dv outstanding pick list.</param> /// <param name="remark">The remark.</param> /// <param name="issuedBy">The issued by.</param> /// <param name="etCurrentDate">The et current date.</param> /// <returns></returns> /// <exception cref="System.Exception"></exception> public static Order SaveIssueTransaction(int orderID, ref DataView dvOutstandingPickList, string remark, string issuedBy, DateTime etCurrentDate) { // Add the IssueDocID field dvOutstandingPickList.Table.Columns.Add("IssueDocID"); PickList plst = new PickList(); IssueDoc issDoc = new IssueDoc(); ReceiveDoc recDoc = new ReceiveDoc(); BLL.Order ord = new BLL.Order(); ord.LoadByPrimaryKey(orderID); plst.LoadByOrderID(ord.ID); foreach (DataRowView drv in dvOutstandingPickList) { // Pseudo: // for each row in the picklist // undate the issue document // subtract the issued quantity from the receive doc // subtract the issued quantity from recieve pallet // subtract the issued the reserved quantity irregardless of the quantity issued. //Saving the new Issue issue if (Convert.ToDecimal(drv["BUPICKED"]) == 0) { continue; } if (Convert.ToDecimal(drv["SKUPicked"]) != Convert.ToDecimal(drv["SKUTOPICK"])) { drv["Cost"] = Convert.ToDecimal(drv["SKUPicked"]) * Convert.ToDecimal(drv["UnitPrice"]); } // Select the receive doc that is associated with this issue. recDoc.LoadByPrimaryKey(Convert.ToInt32(drv["ReceiveDocID"])); issDoc.AddNew(); issDoc.StoreId = Convert.ToInt32(drv["StoreID"]); issDoc.RefNo = ord.RefNo; if (!ord.IsColumnNull("RequestedBy")) { issDoc.ReceivingUnitID = ord.RequestedBy; } // TOFIX: // TODO: // Lord have mercy kind of hack to avoid the feb date problem // this needs to be fixed for pagume also issDoc.Date = etCurrentDate; issDoc.EurDate = DateTimeHelper.ServerDateTime; issDoc.RecievDocID = Convert.ToInt32(drv["ReceiveDocID"]); issDoc.IsApproved = true; issDoc.IsTransfer = false; issDoc.Remark = remark; issDoc.ItemID = Convert.ToInt32(drv["ItemID"]); issDoc.Quantity = Convert.ToDecimal(drv["BUPICKED"]); issDoc.NoOfPack = Convert.ToDecimal(drv["SKUPICKED"]); issDoc.QtyPerPack = Convert.ToInt32(drv["SKUBU"]); issDoc.BatchNo = drv["BatchNumber"].ToString(); issDoc.UnitID = recDoc.UnitID; issDoc.ManufacturerID = recDoc.ManufacturerId; if (drv["Cost"] != DBNull.Value) { issDoc.Cost = Convert.ToDouble(drv["Cost"]); issDoc.SellingPrice = Convert.ToDecimal(drv["UnitPrice"]); if (!recDoc.IsColumnNull("Cost")) { issDoc.UnitCost = Convert.ToDecimal(recDoc.Cost); } } issDoc.OrderID = orderID; issDoc.IssuedBy = issuedBy; // TODO: is this the right place where we need to pick the physical store ID from? // check it against the receipt pallet physical store. if (!recDoc.IsColumnNull("PhysicalStoreID")) { issDoc.PhysicalStoreID = recDoc.PhysicalStoreID; } if (!recDoc.IsColumnNull("InventoryPeriodID")) { //Todo: Remove for Inventory issDoc.InventoryPeriodID = recDoc.InventoryPeriodID; } if (!recDoc.IsColumnNull("Margin")) { issDoc.Margin = (decimal)recDoc.Margin; } //Replaced by issDoc.PLDetailID = Convert.ToInt32(drv["PLDetailID"]); BLL.Balance bal = new Balance(); BLL.ReceiveDoc rd = new ReceiveDoc(); rd.LoadByPrimaryKey(issDoc.RecievDocID); decimal currentBalance = bal.GetSoh(issDoc.ItemID, rd.UnitID, issDoc.StoreId, issDoc.Date.Month, issDoc.Date.Year); if (currentBalance < issDoc.NoOfPack) { throw new Exception(string.Format("The item {0} is not available in {1} Qty.", drv["FullItemName"].ToString(), issDoc.NoOfPack)); } // This is a field that is not applicable on the hub edition // It is about the dispensing unit quantity and there is no such thing as Dispensing unit // in the hub edition issDoc.DUSOH = 0; issDoc.RecomendedQty = 0;// ((recQty > 0) ? Convert.ToInt64(recQty) : 0); // End DU issDoc.DispatchConfirmed = false; issDoc.Save(); drv["IssueDocID"] = issDoc.ID; // updating the receiving doc //long prevQuantityLeft = recDoc.QuantityLeft; recDoc.QuantityLeft = recDoc.QuantityLeft - issDoc.Quantity; if (recDoc.QuantityLeft < 0) { //Possibly the wrong ReceiveDoc Entry chosen BLL.Item itm = new Item(); itm.LoadByPrimaryKey(recDoc.ItemID); throw new Exception(string.Format("Quantity problem detected for the item {0}", itm.FullItemName)); } //long recDoc.Out = (recDoc.QuantityLeft == 0) ? true : false; recDoc.Save(); ReceivePallet rp = new ReceivePallet(); int id = Convert.ToInt32(drv["ReceivePalletID"]); rp.LoadByPrimaryKey(id); if (rp.IsColumnNull("Balance")) { rp.Balance = rp.ReceivedQuantity; } rp.Balance -= issDoc.Quantity; if (rp.Balance < 0) { BLL.Item itm = new Item(); itm.LoadByPrimaryKey(recDoc.ItemID); throw new Exception(string.Format("Quantity problem detected for the item {0}", itm.FullItemName)); } decimal totReservedQty = Convert.ToDecimal(drv["QuantityInBU"]); if (rp.IsColumnNull("ReservedStock")) { rp.ReservedStock = 0; } rp.ReservedStock -= totReservedQty; if (rp.ReservedStock < 0) //If there has been a quantity problem somewhere { rp.ReservedStock = 0; } rp.Save(); } plst.IsConfirmed = true; ord.ChangeStatus(OrderStatus.Constant.ISSUED, CurrentContext.UserId); plst.Save(); ord.Save(); return(ord); }
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; } } }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { var us = new User(); var userID = MainWindow.LoggedinId; us.LoadByPrimaryKey(userID); var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode); if(dr==null)return; if (us.UserName != "admin") { XtraMessageBox.Show("You don't have the privilege to update reference number!", "Caution"); return; } if (XtraMessageBox.Show("Are You Sure, You want to delete this?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { var dis = new IssueDoc(); DataTable dtbl = dis.GetTransactionByRefNo((string)dr["RefNo"]); foreach (DataRow dataRow in dtbl.Rows) { AddIssueDocDeleted(dataRow); dataRow.Delete(); } dis.MarkAsDeleted(); dis.Save(); XtraMessageBox.Show("Item successfully deleted.", "Success"); } }
/// <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); }