public static XtraReport GetCostBuildUpPrintout(string GRNString, int ReceiptID) { BLL.Receipt receipt = new BLL.Receipt(ReceiptID); CenterCostCalculator GRV = new CenterCostCalculator(); GRV.LoadGRV(ReceiptID); GRV.LoadCostBuilUp(false, GRNString); HCMIS.Desktop.Reports.CostAnalysisSubReport xReportCostAnalysis = new HCMIS.Desktop.Reports.CostAnalysisSubReport(); xReportCostAnalysis.DataSource = GRV.CostAnalysis(GRNString); HCMIS.Desktop.Reports.CostBuildUp xReportCostBuildUp = new HCMIS.Desktop.Reports.CostBuildUp(); xReportCostBuildUp.DataSource = GRV.CostBuildUp.DataTable.DefaultView; xReportCostBuildUp.xrDate.Text = EthiopianDate.EthiopianDate.GregorianToEthiopian(BLL.DateTimeHelper.ServerDateTime); xReportCostBuildUp.xrSubreport1.ReportSource = xReportCostAnalysis; xReportCostBuildUp.xrCostedBy.Text = CurrentContext.LoggedInUserName; ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); DataTable Users = receiveDocConfirmation.GetUserNamebyReceipt(ReceiptID); if (Users.Rows.Count > 0) { xReportCostBuildUp.xrCostedBy.Text = Users.Rows[0]["CostedBy"].ToString(); xReportCostBuildUp.xrCheckedBy.Text = Users.Rows[0]["CheckedBy"].ToString(); } return(xReportCostBuildUp); }
private void repIsConfirmed_CheckedChanged(object sender, EventArgs e) { DataRow Masterdr = gridMasterView.GetFocusedDataRow(); Masterdr["IsConfirmed"] = (sender as CheckEdit).Checked; bool IsConfirmed = Convert.ToBoolean(Masterdr["IsConfirmed"]); if (XtraMessageBox.Show(String.Format("Are you sure you want to {0}", IsConfirmed?"Confirm":"UnConfirm"), "Are you sure...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); string ReceiveDocs = Masterdr["ReceiveDocIds"].ToString(); receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(ReceiveDocs, IsConfirmed?ReceiptConfirmationStatus.Constants.GRNF_PRINTED:ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED); } }
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 void btnMovingAverage_Click(object sender, EventArgs e) { MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); var dialogResult = XtraMessageBox.Show( String.Format("Are you Sure you want to Set the Price for {0}", txtItemName.Text), "Are you sure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dialogResult == DialogResult.Cancel) { return; } if (dialogResult == DialogResult.Yes) { try { transaction.BeginTransaction(); // This is where we set the Price JournalService journalService = new JournalService(); journalService.StartRecordingSession(); costElement.SavePrice(CurrentContext.UserId, "", journalService, ChangeMode.BeginningBalance); journalService.CommitRecordingSession(); journalService.StartRecordingSession(); costElement.ConfirmPrice(CurrentContext.UserId, "", journalService, ChangeMode.BeginningBalance); journalService.CommitRecordingSession(); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.SavePrice(costElement, CurrentContext.UserId); ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(receiveDocs, ReceiptConfirmationStatus.Constants.GRV_PRINTED, ReceiptConfirmationStatus.Constants.PRICE_CALCULATED); transaction.CommitTransaction(); this.Close(); } catch (Exception exception) { transaction.RollbackTransaction(); XtraMessageBox.Show("Error : " + exception.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Error); throw exception; } } }
public static XtraReport GetCostAnalysisPrintout(string GRNString, int ReceiptID) { BLL.Receipt receipt = new BLL.Receipt(ReceiptID); CostCalculator GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); GRV.LoadGRVForCostAnalysis(ReceiptID); HCMIS.Desktop.Reports.PreviousCostPrintout xReportCostBuildUp = new HCMIS.Desktop.Reports.PreviousCostPrintout(); xReportCostBuildUp.DataSource = GRV.PreviousStock; HCMIS.Desktop.Reports.CostAnalysisSubReport xReportCostAnalysis = new HCMIS.Desktop.Reports.CostAnalysisSubReport(); xReportCostAnalysis.DataSource = GRV.CostAnalysis(GRNString); HCMIS.Desktop.Reports.CostCalculationPrintout xReportCostCalculationPrintOut = new HCMIS.Desktop.Reports.CostCalculationPrintout(); xReportCostCalculationPrintOut.DataSource = GRV.GRVDetail; HCMIS.Desktop.Reports.CostReport xReportCostReport = new HCMIS.Desktop.Reports.CostReport(); xReportCostReport.DataSource = GRV.CostAnalysis(GRNString); xReportCostReport.xrDate.Text = EthiopianDate.EthiopianDate.GregorianToEthiopian(BLL.DateTimeHelper.ServerDateTime); ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); DataTable Users = receiveDocConfirmation.GetUserNamebyReceipt(ReceiptID); if (Users.Rows.Count > 0) { xReportCostReport.xrCostedBy.Text = Users.Rows[0]["CostedBy"].ToString(); xReportCostReport.xrCheckedBy.Text = Users.Rows[0]["CheckedBy"].ToString(); } xReportCostReport.xrWarehouse.Text = receipt.GetWarehouse(); xReportCostReport.subReportCostCalculation.ReportSource = xReportCostCalculationPrintOut; xReportCostReport.xrSubreportCostBuildup.ReportSource = xReportCostBuildUp; xReportCostReport.xrSubreportCostAnalysis.ReportSource = xReportCostAnalysis; xReportCostReport.ShowPrintStatusDialog = true; xReportCostReport.CreateDocument(); xReportCostReport.PrintingSystem.Document.AutoFitToPagesWidth = 1; return(xReportCostReport); }
private void btnConfirmAll_Click(object sender, EventArgs e) { if (lkWarehouse.EditValue != null && lkAccount.EditValue != null && XtraMessageBox.Show(String.Format("Are you sure you want to Confirm?"), "Are you sure...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int StoreID = Convert.ToInt32(lkAccount.EditValue); int WarehouseID = Convert.ToInt32(lkWarehouse.EditValue); ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); string ReceiveDocs = ""; foreach (DataRowView drv in (gridMain.DataSource as DataView)) { ReceiveDocs = ReceiveDocs != "" ? ReceiveDocs + ',' + drv["ReceiveDocIDs"].ToString() : ReceiveDocs + drv["ReceiveDocIDs"].ToString(); } receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(ReceiveDocs, ReceiptConfirmationStatus.Constants. GRNF_PRINTED); XtraMessageBox.Show("Price has been successfully confirmed", "Success...", MessageBoxButtons.OK, MessageBoxIcon.Information); lkWarehouse_EditValueChanged(null, null); } }
public void CloneReceiveForErrorCorrection(int confirmationStatusID, ReceivePallet receivePallet, ReceiveDoc receiveDoc, decimal pack, User user, int itemId, int storeId, int receiptId, int manufacturerId, ItemUnit itemUnit, DateTime convertedEthDate, bool changeExpiryDate = false, DateTime?ExpiryDate = null, bool changeBatchNo = false, string batchNo = null) { var newReceiveDoc = receiveDoc.Clone(); newReceiveDoc.ItemID = itemId; if (changeBatchNo) { newReceiveDoc.BatchNo = batchNo; } if (changeExpiryDate) { if (ExpiryDate.HasValue) { newReceiveDoc.ExpDate = ExpiryDate.Value; } else { newReceiveDoc.SetColumnNull("ExpDate"); } } newReceiveDoc.ManufacturerId = manufacturerId; newReceiveDoc.SetColumn("UnitID", itemUnit.ID); newReceiveDoc.Quantity = pack * itemUnit.QtyPerUnit; newReceiveDoc.QuantityLeft = pack * itemUnit.QtyPerUnit; newReceiveDoc.NoOfPack = pack; newReceiveDoc.InvoicedNoOfPack = pack; newReceiveDoc.QtyPerPack = itemUnit.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = storeId; newReceiveDoc.RefNo = receiptId.ToString(); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptId; newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); ReceivePallet newReceivePallet = new ReceivePallet(); newReceivePallet.AddNew(); newReceivePallet.ReceiveID = newReceiveDoc.ID; newReceivePallet.ReceivedQuantity = pack * itemUnit.QtyPerUnit; newReceivePallet.Balance = pack * itemUnit.QtyPerUnit; newReceivePallet.ReservedStock = 0; newReceivePallet.BoxSize = 0; newReceivePallet.PalletID = receivePallet.PalletID; newReceivePallet.IsOriginalReceive = true; if (!receivePallet.IsColumnNull("PalletLocationID")) { newReceivePallet.PalletLocationID = receivePallet.PalletLocationID; } newReceivePallet.Save(); }
public ReceiveDoc CreateInventoryReceive(Inventory inventory, int receiptID, Inventory.QuantityType quantityType, DateTime ethiopianDate, User user) { ItemUnit itemUnit = new ItemUnit(); itemUnit.LoadByPrimaryKey(inventory.UnitID); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.AddNew(); receiveDoc.ItemID = inventory.ItemID; receiveDoc.UnitID = inventory.UnitID; receiveDoc.ManufacturerId = inventory.ManufacturerID; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.Date = ethiopianDate; receiveDoc.EurDate = DateTimeHelper.ServerDateTime; receiveDoc.PhysicalStoreID = inventory.PhysicalStoreID; receiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); decimal quantity = quantityType == Inventory.QuantityType.Sound ? inventory.InventorySoundQuantity : quantityType == Inventory.QuantityType.Damaged ? inventory.InventoryDamagedQuantity :inventory.InventoryExpiredQuantity; if (quantityType == Inventory.QuantityType.Damaged) { receiveDoc.ShortageReasonID = ShortageReasons.Constants.DAMAGED; } receiveDoc.Quantity = receiveDoc.QuantityLeft = quantity * itemUnit.QtyPerUnit; receiveDoc.NoOfPack = receiveDoc.InvoicedNoOfPack = quantity; receiveDoc.QtyPerPack = itemUnit.QtyPerUnit; receiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); receiveDoc.Out = false; receiveDoc.ReceivedBy = user.UserName; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.RefNo = "BeginningBalance"; decimal cost = 0; decimal margin = 0; if (!inventory.IsColumnNull("Cost")) { cost = inventory.Cost; } if (!inventory.IsColumnNull("Margin")) { margin = inventory.Margin; } receiveDoc.Cost = Convert.ToDouble(cost); receiveDoc.PricePerPack = Convert.ToDouble(cost); receiveDoc.UnitCost = cost; receiveDoc.Margin = Convert.ToDouble(margin); receiveDoc.SellingPrice = Convert.ToDouble(BLL.Settings.IsCenter ? cost : cost * (1 + margin)); receiveDoc.SupplierID = 2; //TODO: HARDCODE WARNING WARNING WARNING receiveDoc.DeliveryNote = false; receiveDoc.Confirmed = true; receiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; receiveDoc.ReturnedStock = false; receiveDoc.ReceiptID = receiptID; receiveDoc.RefNo = "BeginningBalance"; receiveDoc.InventoryPeriodID = inventory.InventoryPeriodID; receiveDoc.IsDamaged = (quantityType == Inventory.QuantityType.Damaged || quantityType == Inventory.QuantityType.Expired); receiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = receiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED; rdConf.Save(); //TODO: Create Receive Pallet Here PalletLocation palletLocation = new PalletLocation(); palletLocation.LoadByPrimaryKey(quantityType != Inventory.QuantityType.Damaged ? inventory.PalletLocationID : inventory.DamagedPalletLocationID); ReceivePallet receivePallet = new ReceivePallet(); receivePallet.AddNew(); receivePallet.Balance = quantity * itemUnit.QtyPerUnit; receivePallet.ReceivedQuantity = quantity * itemUnit.QtyPerUnit; receivePallet.ReservedStock = 0; receivePallet.ReceiveID = receiveDoc.ID; if (palletLocation.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.Save(); palletLocation.PalletID = pallet.ID; palletLocation.Save(); } receivePallet.PalletID = palletLocation.PalletID; receivePallet.PalletLocationID = palletLocation.ID; receivePallet.BoxSize = 0; receivePallet.IsOriginalReceive = true; receivePallet.Save(); return(receiveDoc); }
private ReceiveDoc CreateReceiveDocForInventory(Inventory inventory, int confirmationStatusID, decimal foundQty, int receiptID, DateTime convertedEthDate, User user, string remark) { ReceiveDoc newReceiveDoc = new ReceiveDoc(); newReceiveDoc.AddNew(); newReceiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.ItemID = inventory.ItemID; newReceiveDoc.ManufacturerId = inventory.ManufacturerID; newReceiveDoc.SetColumn("UnitID", inventory.UnitID); if (!inventory.IsColumnNull("SupplierID")) { newReceiveDoc.SupplierID = inventory.SupplierID; } BLL.ItemUnit iu = new ItemUnit(); iu.LoadByPrimaryKey(inventory.UnitID); newReceiveDoc.Quantity = newReceiveDoc.QuantityLeft = foundQty * iu.QtyPerUnit; newReceiveDoc.NoOfPack = foundQty; newReceiveDoc.InvoicedNoOfPack = foundQty; newReceiveDoc.QtyPerPack = iu.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); newReceiveDoc.Out = false; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = inventory.ActivityID; newReceiveDoc.SetColumn("LocalBatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.RefNo = receiptID.ToString(); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("IsApproved", DBNull.Value); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.SetColumn("SellingPrice", inventory.GetColumn("SellingPrice")); newReceiveDoc.SetColumn("UnitCost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("PricePerPack", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("DeliveryNote", DBNull.Value); newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptID; newReceiveDoc.SetColumn("Margin", inventory.GetColumn("Margin")); newReceiveDoc.RefNo = "BeginningBalance"; if (!string.IsNullOrEmpty(remark)) { newReceiveDoc.IsDamaged = false; } if (!string.IsNullOrEmpty(remark)) { newReceiveDoc.Remark = remark; } newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); return(newReceiveDoc); }
private ReceiveDoc CreateReceiveDocForInventory(Inventory inventory, int confirmationStatusID, decimal foundQty, int receiptID, DateTime convertedEthDate, User user,string remark) { ReceiveDoc newReceiveDoc = new ReceiveDoc(); newReceiveDoc.AddNew(); newReceiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.ItemID = inventory.ItemID; newReceiveDoc.ManufacturerId = inventory.ManufacturerID; newReceiveDoc.SetColumn("UnitID", inventory.UnitID); if (!inventory.IsColumnNull("SupplierID")) newReceiveDoc.SupplierID = inventory.SupplierID; BLL.ItemUnit iu = new ItemUnit(); iu.LoadByPrimaryKey(inventory.UnitID); newReceiveDoc.Quantity = newReceiveDoc.QuantityLeft = foundQty*iu.QtyPerUnit; newReceiveDoc.NoOfPack = foundQty; newReceiveDoc.InvoicedNoOfPack = foundQty; newReceiveDoc.QtyPerPack = iu.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); newReceiveDoc.Out = false; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = inventory.ActivityID; newReceiveDoc.SetColumn("LocalBatchNo", inventory.GetColumn("BatchNo")); newReceiveDoc.RefNo = receiptID.ToString(); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("IsApproved", DBNull.Value); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.SetColumn("SellingPrice", inventory.GetColumn("SellingPrice")); newReceiveDoc.SetColumn("UnitCost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("Cost", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("PricePerPack", inventory.GetColumn("Cost")); newReceiveDoc.SetColumn("DeliveryNote", DBNull.Value); newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptID; newReceiveDoc.SetColumn("Margin", inventory.GetColumn("Margin")); newReceiveDoc.RefNo = "BeginningBalance"; if(!string.IsNullOrEmpty(remark)) newReceiveDoc.IsDamaged = false; if (!string.IsNullOrEmpty(remark)) { newReceiveDoc.Remark = remark; } newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); return newReceiveDoc; }
public ReceiveDoc CreateInventoryReceive(Inventory inventory,int receiptID,Inventory.QuantityType quantityType,DateTime ethiopianDate,User user) { ItemUnit itemUnit = new ItemUnit(); itemUnit.LoadByPrimaryKey(inventory.UnitID); ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.AddNew(); receiveDoc.ItemID = inventory.ItemID; receiveDoc.UnitID = inventory.UnitID; receiveDoc.ManufacturerId = inventory.ManufacturerID; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.Date = ethiopianDate; receiveDoc.EurDate = DateTimeHelper.ServerDateTime; receiveDoc.PhysicalStoreID = inventory.PhysicalStoreID; receiveDoc.SetColumn("BatchNo", inventory.GetColumn("BatchNo")); decimal quantity = quantityType == Inventory.QuantityType.Sound ? inventory.InventorySoundQuantity : quantityType == Inventory.QuantityType.Damaged ? inventory.InventoryDamagedQuantity :inventory.InventoryExpiredQuantity; if(quantityType == Inventory.QuantityType.Damaged) receiveDoc.ShortageReasonID = ShortageReasons.Constants.DAMAGED; receiveDoc.Quantity = receiveDoc.QuantityLeft = quantity * itemUnit.QtyPerUnit; receiveDoc.NoOfPack = receiveDoc.InvoicedNoOfPack = quantity; receiveDoc.QtyPerPack = itemUnit.QtyPerUnit; receiveDoc.SetColumn("ExpDate", inventory.GetColumn("ExpiryDate")); receiveDoc.Out = false; receiveDoc.ReceivedBy = user.UserName; receiveDoc.StoreID = inventory.ActivityID; receiveDoc.RefNo = "BeginningBalance"; decimal cost = 0; decimal margin = 0; if (!inventory.IsColumnNull("Cost")) { cost = inventory.Cost; } if(!inventory.IsColumnNull("Margin")) { margin = inventory.Margin; } receiveDoc.Cost = Convert.ToDouble(cost); receiveDoc.PricePerPack = Convert.ToDouble(cost); receiveDoc.UnitCost = cost; receiveDoc.Margin = Convert.ToDouble(margin); receiveDoc.SellingPrice = Convert.ToDouble(BLL.Settings.IsCenter ? cost : cost * (1 + margin)); receiveDoc.SupplierID = 2; //TODO: HARDCODE WARNING WARNING WARNING receiveDoc.DeliveryNote = false; receiveDoc.Confirmed = true; receiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; receiveDoc.ReturnedStock = false; receiveDoc.ReceiptID = receiptID; receiveDoc.RefNo = "BeginningBalance"; receiveDoc.InventoryPeriodID = inventory.InventoryPeriodID; receiveDoc.IsDamaged = (quantityType == Inventory.QuantityType.Damaged || quantityType == Inventory.QuantityType.Expired); receiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = receiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED; rdConf.Save(); //TODO: Create Receive Pallet Here PalletLocation palletLocation = new PalletLocation(); palletLocation.LoadByPrimaryKey(quantityType != Inventory.QuantityType.Damaged ? inventory.PalletLocationID : inventory.DamagedPalletLocationID); ReceivePallet receivePallet = new ReceivePallet(); receivePallet.AddNew(); receivePallet.Balance = quantity * itemUnit.QtyPerUnit; receivePallet.ReceivedQuantity = quantity * itemUnit.QtyPerUnit; receivePallet.ReservedStock = 0; receivePallet.ReceiveID = receiveDoc.ID; if(palletLocation.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.Save(); palletLocation.PalletID = pallet.ID; palletLocation.Save(); } receivePallet.PalletID = palletLocation.PalletID; receivePallet.PalletLocationID =palletLocation.ID; receivePallet.BoxSize = 0; receivePallet.IsOriginalReceive = true; receivePallet.Save(); return receiveDoc; }
public void CloneReceiveForErrorCorrection(int confirmationStatusID, ReceivePallet receivePallet, ReceiveDoc receiveDoc, decimal pack, User user, int itemId, int storeId, int receiptId, int manufacturerId, ItemUnit itemUnit, DateTime convertedEthDate, bool changeExpiryDate = false, DateTime? ExpiryDate = null, bool changeBatchNo = false, string batchNo = null) { var newReceiveDoc = receiveDoc.Clone(); newReceiveDoc.ItemID = itemId; if (changeBatchNo) { newReceiveDoc.BatchNo = batchNo; } if (changeExpiryDate) { if (ExpiryDate.HasValue) { newReceiveDoc.ExpDate = ExpiryDate.Value; } else { newReceiveDoc.SetColumnNull("ExpDate"); } } newReceiveDoc.ManufacturerId = manufacturerId; newReceiveDoc.SetColumn("UnitID", itemUnit.ID); newReceiveDoc.Quantity = pack * itemUnit.QtyPerUnit; newReceiveDoc.QuantityLeft = pack * itemUnit.QtyPerUnit; newReceiveDoc.NoOfPack = pack; newReceiveDoc.InvoicedNoOfPack = pack; newReceiveDoc.QtyPerPack = itemUnit.QtyPerUnit; newReceiveDoc.Date = convertedEthDate; newReceiveDoc.ReceivedBy = user.UserName; newReceiveDoc.StoreID = storeId; newReceiveDoc.RefNo = receiptId.ToString(); newReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; newReceiveDoc.Confirmed = true; newReceiveDoc.ConfirmedDateTime = DateTimeHelper.ServerDateTime; newReceiveDoc.ReturnedStock = false; newReceiveDoc.ReceiptID = receiptId; newReceiveDoc.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = newReceiveDoc.ID; rdConf.ReceivedByUserID = user.ID; rdConf.ReceiptConfirmationStatusID = confirmationStatusID; rdConf.Save(); ReceivePallet newReceivePallet = new ReceivePallet(); newReceivePallet.AddNew(); newReceivePallet.ReceiveID = newReceiveDoc.ID; newReceivePallet.ReceivedQuantity = pack * itemUnit.QtyPerUnit; newReceivePallet.Balance = pack * itemUnit.QtyPerUnit; newReceivePallet.ReservedStock = 0; newReceivePallet.BoxSize = 0; newReceivePallet.PalletID = receivePallet.PalletID; newReceivePallet.IsOriginalReceive = true; if (!receivePallet.IsColumnNull("PalletLocationID")) { newReceivePallet.PalletLocationID = receivePallet.PalletLocationID; } newReceivePallet.Save(); }
/// <summary> /// Returns an extra report containing the GRNF. /// This function is used for creating the report for the first time as well (Not just export). Which is why we can't /// just use the overload with the ReceiptConfirmationPrintoutID as a parameter. /// </summary> /// <param name="receiptID"></param> /// <param name="IDPrinted">Use this if you're trying to get a GRNF printed previously using some ID</param> /// <param name="isDocumentBrowser">Use this For Docuement Browser </param> /// <returns></returns> public static XtraReport CreateGRNFPrintout(int receiptID, int?IDPrinted, bool isDocumentBrowser, FiscalYear fiscalYear) { ReceiptConfirmationPrintoutStore printout = new ReceiptConfirmationPrintoutStore(CurrentContext.LoggedInUserName); BLL.ReceiptConfirmationPrintout rc = new BLL.ReceiptConfirmationPrintout(); printout.BranchName.Text = GeneralInfo.Current.HospitalName; printout.xrGRVLabel.Text = "GRNF No."; int printedID; BLL.ReceiveDoc rDoc = new ReceiveDoc(); rDoc.LoadByReceiptID(receiptID); var activity = new Activity(); activity.LoadByPrimaryKey(rDoc.StoreID); var supplier = new Supplier(); supplier.LoadByPrimaryKey(rDoc.SupplierID); var hsup = new Supplier(); DataTable homeOffice = hsup.GetHubHeadOffice(); if (supplier.ID == (int)homeOffice.Rows[0]["SupplierID"] && !Settings.IsCenter) { printout.ReportType = ReceiptConfirmationPrintoutStore.GRNFReportType.IGRV; } else if (supplier.ID != (int)homeOffice.Rows[0]["SupplierID"]) { printout.ReportType = ReceiptConfirmationPrintoutStore.GRNFReportType.GRV; } if (rDoc.RowCount == 0 && isDocumentBrowser) { rDoc.LoadDeletedByReceiptID(receiptID); } else if (rDoc.RowCount == 0) { throw new Exception("This Receipt Doesn't have corresponding Receipt Doc Entries."); } if (rDoc.ReturnedStock) { BLL.Institution ru = new Institution(); BLL.IssueDoc issueDoc = new IssueDoc(); if (!rDoc.IsColumnNull("ReturnedFromIssueDocID")) { issueDoc.LoadByPrimaryKey(rDoc.ReturnedFromIssueDocID); ru.LoadByPrimaryKey(issueDoc.ReceivingUnitID); } else { BLL.PO po = new PO(); po.LoadByReceiptID(receiptID); ru.LoadByPrimaryKey(Int32.Parse(po.RefNo)); } printout.xrFromFacilityValue.Text = ru.Name; printout.ReportType = ReceiptConfirmationPrintoutStore.GRNFReportType.SRM; } // determine if this is a transfer? account to account or store to store Receipt receipt = new Receipt(); receipt.LoadByPrimaryKey(receiptID); printedID = rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 1, IDPrinted, null, fiscalYear); DataTable dataTable = rc.DefaultView.ToTable(); printout.DataSource = dataTable; printout.xrLabelStoreName.Text = activity.FullActivityName; ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); DataTable Users = receiveDocConfirmation.GetUserNamebyReceipt(receiptID); if (Users.Rows.Count > 0) { printout.PreparedBy.Text = Users.Rows[0]["ReceivedBy"].ToString(); printout.CheckedBy.Text = Users.Rows[0]["ConfirmedBy"].ToString(); } if (ReceiveDoc.IsThereShortageOrDamage(receiptID)) { ReceiptConfirmationShortagePrintout printoutShortage = new ReceiptConfirmationShortagePrintout(); rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, true, 1, printedID, null, fiscalYear); printoutShortage.DataSource = rc.DefaultView.ToTable(); printout.xrShortageReport.ReportSource = printoutShortage; printout.PrintingSystem.ContinuousPageNumbering = true; } else { printout.ReportFooter.Visible = false; } CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx(); //dtDate.CustomFormat = "dd/MM/yyyy"; dtDate.Value = rDoc.EurDate; printout.Date.Text = dtDate.Text; if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { return(CreateModel19Printout(dataTable.DefaultView.ToTable(), dtDate.Text)); } return(printout); }
private void btnApprove_Click(object sender, EventArgs e) { //dxCostingValidation.RemoveControlError(lkPeriod); if (!dxCostingValidation.Validate()) { return; } if (lkWarehouse.EditValue != null && lkAccount.EditValue != null && XtraMessageBox.Show(String.Format("Are you sure you want to Approve All Items, Once Approved the item will be available for release"), "Are you sure...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); string receiveDocs = ""; string rdPendingAverages = ""; var ledgerService = new LedgerService(); DataView dataView = (gridMain.DataSource as DataView); dataView.RowFilter = "PricePerPack <>0 and isConfirmed = 1"; foreach (DataRowView drv in dataView) { var costElement = new CostElement { ItemID = Convert.ToInt32(drv["ItemID"]), ItemUnitID = Convert.ToInt32(drv["UnitID"]), ManufacturerID = Convert.ToInt32(drv["ManufacturerID"]), MovingAverageID = Convert.ToInt32(drv["MovingAverageID"]) }; var ledgerObject = ledgerService.GetLedger(costElement.ItemID, costElement.ItemUnitID, costElement.ManufacturerID, costElement.MovingAverageID); costElement.UnitCost = Math.Round(Convert.ToDouble(ledgerObject.UnitCost), BLL.Settings.NoOfDigitsAfterTheDecimalPoint, MidpointRounding.AwayFromZero); costElement.AverageCost = Math.Round(Convert.ToDouble(drv["PricePerPack"]), BLL.Settings.NoOfDigitsAfterTheDecimalPoint, MidpointRounding.AwayFromZero); costElement.Margin = Convert.ToDouble(drv["Margin"]) / 100; costElement.SellingPrice = costElement.AverageCost * (1 + costElement.Margin); var isSound = drv["Remark"].Equals("Sound"); if ((Math.Abs(costElement.UnitCost - costElement.AverageCost) == 0) || !isSound) { receiveDocs = receiveDocs != "" ? receiveDocs + ',' + drv["ReceiveDocIDs"].ToString() : receiveDocs + drv["ReceiveDocIDs"].ToString(); } else if (ReceiveDoc.GetSoundStock(costElement) > 0) { rdPendingAverages = rdPendingAverages != "" ? rdPendingAverages + ',' + drv["ReceiveDocIDs"].ToString() : rdPendingAverages + drv["ReceiveDocIDs"].ToString(); } else { IJournalService journal = new JournalService(); journal.StartRecordingSession(); costElement.SavePrice(CurrentContext.UserId, "", journal, ChangeMode.BeginningBalance); journal.CommitRecordingSession(); journal.StartRecordingSession(); costElement.ConfirmPrice(CurrentContext.UserId, "", journal, ChangeMode.BeginningBalance); journal.CommitRecordingSession(); receiveDocs = receiveDocs != "" ? receiveDocs + ',' + drv["ReceiveDocIDs"].ToString() : receiveDocs + drv["ReceiveDocIDs"].ToString(); } } receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(receiveDocs, ReceiptConfirmationStatus.Constants.GRV_PRINTED, ReceiptConfirmationStatus.Constants.GRNF_PRINTED); receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(rdPendingAverages, ReceiptConfirmationStatus.Constants. PRICE_CALCULATED, ReceiptConfirmationStatus.Constants.GRNF_PRINTED); XtraMessageBox.Show("Price has been successfully confirmed", "Success...", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exception) { XtraMessageBox.Show(exception.Message, "Success...", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } lkWarehouse_EditValueChanged(null, null); } }