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); DeletedRelatedModel(dataRow); dataRow.Delete(); } dis.MarkAsDeleted(); dis.Save(); XtraMessageBox.Show("Item successfully deleted.", "Success"); } }
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 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 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 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; }
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) { 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.EurDate = transfer.EurDate; 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.EurDate = transfer.EurDate; 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 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"); } }
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 toolStripMenuItem2_Click(object sender, EventArgs e) { var us = new User(); var userID = MainWindow.LoggedinId; us.LoadByPrimaryKey(userID); DataRow dr = grdLogIssue.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); DeletedRelatedModel(iss); iss.MarkAsDeleted(); iss.Save(); DataTable dtRec = iss.GetAllTransaction(Convert.ToInt32(cboStores.EditValue)); gridIssues.DataSource = dtRec; } } }
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); } } }
public IssueDoc CreateIssueFromPicklist(PickListDetail picklistDetail,Order order,DateTime convertedEthDate,Issue stvLog,User user) { ReceivePallet receivePallet = new ReceivePallet(); receivePallet.LoadByPrimaryKey(picklistDetail.ReceivePalletID); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(receivePallet.ReceiveID); IssueDoc issueDoc = new IssueDoc(); issueDoc.AddNew(); issueDoc.BatchNo = picklistDetail.BatchNumber; if(!picklistDetail.IsColumnNull("Cost")) issueDoc.Cost = picklistDetail.Cost; issueDoc.Date = convertedEthDate; issueDoc.EurDate = DateTimeHelper.ServerDateTime; issueDoc.StoreId = picklistDetail.StoreID; issueDoc.STVID = stvLog.ID; issueDoc.IsTransfer = true; issueDoc.IssuedBy = user.FullName; issueDoc.ItemID = picklistDetail.ItemID; issueDoc.NoOfPack = picklistDetail.Packs; issueDoc.QtyPerPack = picklistDetail.QtyPerPack; issueDoc.Quantity = picklistDetail.QuantityInBU; issueDoc.OrderID = order.ID; issueDoc.UnitID = receiveDoc.UnitID; issueDoc.ManufacturerID = receiveDoc.ManufacturerId; issueDoc.SetColumn("UnitCost" ,receiveDoc.GetColumn("Cost")); issueDoc.SetColumn("SellingPrice" ,receiveDoc.GetColumn("SellingPrice")); issueDoc.SetColumn("Margin", receiveDoc.GetColumn("Margin")); issueDoc.SetColumn("PhysicalStoreID", receiveDoc.GetColumn("PhysicalStoreID")); issueDoc.PLDetailID = picklistDetail.ID; issueDoc.RecievDocID = picklistDetail.ReceiveDocID; issueDoc.SetColumn("InventoryPeriodID", receiveDoc.GetColumn("InventoryPeriodID")); // This is a deprecated field issueDoc.RecomendedQty = 0;// picklistDetail.Packs; issueDoc.RefNo = stvLog.IDPrinted.ToString(); issueDoc.DispatchConfirmed = false; issueDoc.Save(); //substract from QuantityLeft receiveDoc.QuantityLeft -= picklistDetail.QuantityInBU; if(receiveDoc.QuantityLeft < 0) { receiveDoc.QuantityLeft = 0; } receiveDoc.Save(); receivePallet.Balance -= picklistDetail.QuantityInBU; if(receivePallet.Balance < 0) { receivePallet.Balance=0; } receivePallet.ReservedStock -= picklistDetail.Packs; if(receivePallet.ReservedStock < 0) { receivePallet.ReservedStock = 0; } receivePallet.Save(); return issueDoc; }
public IssueDoc CreateIssueFromPicklist(PickListDetail picklistDetail, Order order, DateTime convertedEthDate, Issue stvLog, User user) { ReceivePallet receivePallet = new ReceivePallet(); receivePallet.LoadByPrimaryKey(picklistDetail.ReceivePalletID); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(receivePallet.ReceiveID); IssueDoc issueDoc = new IssueDoc(); issueDoc.AddNew(); issueDoc.BatchNo = picklistDetail.BatchNumber; if (!picklistDetail.IsColumnNull("Cost")) { issueDoc.Cost = picklistDetail.Cost; } issueDoc.Date = convertedEthDate; issueDoc.EurDate = DateTimeHelper.ServerDateTime; issueDoc.StoreId = picklistDetail.StoreID; issueDoc.STVID = stvLog.ID; issueDoc.IsTransfer = true; issueDoc.IssuedBy = user.FullName; issueDoc.ItemID = picklistDetail.ItemID; issueDoc.NoOfPack = picklistDetail.Packs; issueDoc.QtyPerPack = picklistDetail.QtyPerPack; issueDoc.Quantity = picklistDetail.QuantityInBU; issueDoc.OrderID = order.ID; issueDoc.UnitID = receiveDoc.UnitID; issueDoc.ManufacturerID = receiveDoc.ManufacturerId; issueDoc.SetColumn("UnitCost", receiveDoc.GetColumn("Cost")); issueDoc.SetColumn("SellingPrice", receiveDoc.GetColumn("SellingPrice")); issueDoc.SetColumn("Margin", receiveDoc.GetColumn("Margin")); issueDoc.SetColumn("PhysicalStoreID", receiveDoc.GetColumn("PhysicalStoreID")); issueDoc.PLDetailID = picklistDetail.ID; issueDoc.RecievDocID = picklistDetail.ReceiveDocID; issueDoc.SetColumn("InventoryPeriodID", receiveDoc.GetColumn("InventoryPeriodID")); // This is a deprecated field issueDoc.RecomendedQty = 0;// picklistDetail.Packs; issueDoc.RefNo = stvLog.IDPrinted.ToString(); issueDoc.DispatchConfirmed = false; issueDoc.Save(); //substract from QuantityLeft receiveDoc.QuantityLeft -= picklistDetail.QuantityInBU; if (receiveDoc.QuantityLeft < 0) { receiveDoc.QuantityLeft = 0; } receiveDoc.Save(); receivePallet.Balance -= picklistDetail.QuantityInBU; if (receivePallet.Balance < 0) { receivePallet.Balance = 0; } receivePallet.ReservedStock -= picklistDetail.Packs; if (receivePallet.ReservedStock < 0) { receivePallet.ReservedStock = 0; } receivePallet.Save(); return(issueDoc); }