private void btnChangeReceiptConfirmationStatus_Click(object sender, EventArgs e) { int newReceiptConfirmationStatus = int.Parse(lkReceiptConfirmationStatus.EditValue.ToString()); BLL.ReceiveDoc rd = new ReceiveDoc(); rd.LoadByReceiptID(int.Parse(txtReceiptID.Text)); while (!rd.EOF) { ReceiveDocConfirmation rdc = new ReceiveDocConfirmation(); rdc.LoadByReceiveDocID(rd.ID); rdc.ReceiptConfirmationStatusID = newReceiptConfirmationStatus; rdc.Save(); rd.MoveNext(); } XtraMessageBox.Show("Successful!"); }
private static void HandleReceiveDocDeleting(int receiveDocID, int userID, ReceiveDoc rd) { //Check if there is a Related Picklists var pld = new PickListDetail(); pld.LoadByReceiveDocID(receiveDocID); pld.Rewind(); if(pld.RowCount > 0) { var pl = new PickList(); pl.LoadByPrimaryKey(pld.PickListID); var order = new Order(); order.LoadByPrimaryKey(pl.OrderID); string printedIDs = ""; var stvs = new BLL.Issue(); stvs.Where.PickListID.Value = pl.ID; stvs.Query.Load(); stvs.Rewind(); while (!stvs.EOF) { printedIDs += stvs.IDPrinted.ToString(CultureInfo.InvariantCulture) + " ,"; stvs.MoveNext(); } printedIDs = printedIDs.Remove(printedIDs.Length - 1, 1); throw new Exception( string.Format("Please cancel/void the following Stvs: Ref No = {0} With PrintedIDs : {1}", order.RefNo,printedIDs)); } // Add new record on ReceiveDocDeleted var recDel = ReceiveDocDeleted.AddNewLog(rd, userID); // Delete related ReceivePallet var receivePallet = new BLL.ReceivePallet(); receivePallet.LoadByReceiveDocID(receiveDocID); receivePallet.Rewind(); while(!receivePallet.EOF) { receivePallet.MarkAsDeleted(); receivePallet.MoveNext(); } // Delete related ReceivePriceConfirmation var receivePriceConfirmation = new ReceivePriceConfirmation(); receivePriceConfirmation.LoadByReceiveDocID(rd.ID); receivePriceConfirmation.MarkAsDeleted(); // Delete related ReceiveDocShortage var rdShr = new ReceiveDocShortage(); rdShr.Where.ReceiveDocID.Value = rd.ID; rdShr.Query.Load(); rdShr.Rewind(); while(!rdShr.EOF) { rdShr.MarkAsDeleted(); rdShr.MoveNext(); } // Delete related ReceiveDocConfirmation var rdConf = new ReceiveDocConfirmation(); rdConf.Where.ReceiveDocID.Value = rd.ID; rdConf.Query.Load(); rdConf.Rewind(); while(!rdConf.EOF) { rdConf.MarkAsDeleted(); rdConf.MoveNext(); } rd.MarkAsDeleted(); var transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); transaction.BeginTransaction(); try { receivePallet.Save(); receivePriceConfirmation.Save(); rdShr.Save(); rdConf.Save(); recDel.Save(); rd.Save(); transaction.CommitTransaction(); } catch (Exception exception) { transaction.RollbackTransaction(); throw; } }
/// <summary> /// Saves the new receive doc entry from picklist detail. /// </summary> /// <param name="pld">The PLD.</param> /// <param name="userID">The user ID.</param> /// <param name="activityID">The new store ID.</param> /// <param name="newPhysicalStoreID">The new physical store ID.</param> /// <param name="convertedEthDate">The converted eth date.</param> /// <param name="supplierID">Activity or Store where it has Transfered from </param> /// <exception cref="System.Exception"></exception> internal void SaveNewReceiveDocEntryFromPicklistDetail(PickListDetail pld, int userID, int activityID, int newPhysicalStoreID, DateTime convertedEthDate,int receiptID,int? supplierID) { BLL.User user = new User(); user.LoadByPrimaryKey(userID); BLL.ReceiveDoc rdOriginal = new ReceiveDoc(); rdOriginal.LoadByPrimaryKey(pld.ReceiveDocID); //Now Save the receive doc entry this.AddNew(); this.SetColumn("BatchNo", pld.GetColumn("BatchNumber")); this.ItemID = pld.ItemID; if (supplierID != null) this.SupplierID = supplierID.Value; this.Quantity = pld.QuantityInBU; //this.Date= this.Date = convertedEthDate; this.SetColumn("ExpDate", rdOriginal.GetColumn("ExpDate")); this.Out = false; this.ReceivedBy = user.UserName; this.StoreID = activityID; SetColumn("LocalBatchNo", rdOriginal.GetColumn("LocalBatchNo")); this.RefNo = receiptID.ToString(); this.SetColumn("Cost", rdOriginal.GetColumn("Cost")); this.SetColumn("IsApproved", rdOriginal.GetColumn("IsApproved")); this.ManufacturerId = rdOriginal.ManufacturerId; this.QuantityLeft = this.Quantity; this.NoOfPack = pld.Packs; this.QtyPerPack = rdOriginal.QtyPerPack; this.EurDate = DateTimeHelper.ServerDateTime; this.SetColumn("SellingPrice", rdOriginal.GetColumn("SellingPrice")); this.SetColumn("UnitCost", rdOriginal.GetColumn("Cost")); this.SetColumn("Cost", rdOriginal.GetColumn("Cost")); this.SetColumn("PricePerPack", rdOriginal.GetColumn("Cost")); this.SetColumn("UnitID", rdOriginal.GetColumn("UnitID")); this.SetColumn("DeliveryNote", rdOriginal.GetColumn("DeliveryNote")); this.Confirmed = false; this.ConfirmedDateTime = DateTimeHelper.ServerDateTime; this.ReturnedStock = false; this.ReceiptID = receiptID; this.PhysicalStoreID = newPhysicalStoreID; PhysicalStore physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(newPhysicalStoreID); this.InventoryPeriodID = physicalStore.CurrentInventoryPeriodID; this.SetColumn("Margin", rdOriginal.GetColumn("Margin")); this.InvoicedNoOfPack = pld.Packs; this.IsDamaged = (bool) rdOriginal.GetColumn("IsDamaged"); this.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = this.ID; rdConf.ReceivedByUserID = userID; rdConf.ReceiptConfirmationStatusID = BLL.ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED; rdConf.Save(); //Now Save the palletization. ReceivePallet rp = new ReceivePallet(); rp.AddNew(); rp.ReceivedQuantity = this.Quantity; rp.Balance = this.Quantity; rp.ReservedStock = 0; rp.ReceiveID = this.ID; PalletLocation pLocation = new PalletLocation(); pLocation.LoadFirstOrDefault(newPhysicalStoreID, int.Parse(BLL.StorageType.BulkStore)); if (pLocation.RowCount == 0) { throw new Exception("No locations created in the destination store. Please check if there are Bulk store pallet locations in the physical store."); } else { if (pLocation.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.PalletNo = BLL.Pallet.GetLastPanelNumber() + 1; pallet.StorageTypeID = int.Parse(BLL.StorageType.Free); pallet.Save(); pLocation.PalletID = pallet.ID; } rp.PalletID = pLocation.PalletID; rp.PalletLocationID = pLocation.ID; rp.BoxSize = 0; rp.IsOriginalReceive = true; rp.Save(); } }