private void gridLkEditOrderType_EditValueChanged(object sender, EventArgs e) { if (gridLkEditOrderType.EditValue == null) { return; } var poTypeID = Convert.ToInt32(gridLkEditOrderType.EditValue); var suppliers = Supplier.GetSuppliersByPOType(poTypeID); lkSupplier.Properties.DataSource = suppliers.DefaultView; if (poTypeID == POType.MANUAL_DELIVERYNOTE) { if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { var centerCold = suppliers.AsEnumerable().FirstOrDefault(t => t.Field <int>("SN") == 400034); lkSupplier.EditValue = centerCold != null?centerCold.Field <int>("ID") : -1; } else { var centerCold = suppliers.AsEnumerable().FirstOrDefault(t => t.Field <int>("SN") == 400006); lkSupplier.EditValue = centerCold != null?centerCold.Field <int>("ID") : -1; } } else { var directVendorSuppliers = Supplier.GetDirectVendorSuppliers(); lkSupplier.Properties.DataSource = directVendorSuppliers.DefaultView; lkSupplier.EditValue = directVendorSuppliers.Rows.Count > 0 ? Convert.ToInt32(directVendorSuppliers.Rows[0]["ID"]) : -1; } txtInsurance.Enabled = txtNBEServiceCharge.Enabled = poTypeID != POType.CIP; }
private void HideUnhideColumn() { layoutCenterRequisition.Visibility = BLL.Settings.IsCenter ? LayoutVisibility.Never : LayoutVisibility.Never; colDamaged.Visible = colExpired.Visible = colSOH.Visible = InstitutionIType.IsVaccine(GeneralInfo.Current); }
/// <summary> /// Formats the STV. /// </summary> /// <param name="ord">The ord.</param> /// <param name="dvPriced">The dv priced.</param> /// <param name="stvSentTo">The STV sent to.</param> /// <param name="pl">The pl.</param> /// <param name="deliveryNote">if set to <c>true</c> [delivery note].</param> /// <param name="allowCancelByUser">if set to <c>true</c> [allow cancel by user].</param> /// <exception cref="System.Exception"></exception> private XtraReport FormatSTV(Order ord, DataTable dvPriced, string stvSentTo, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int orderID) { bool hasInsurance = chkIncludeInsurance.Checked; string accountName = txtConfirmFromStore.Text; string transferType = null; int?orderTypeID = null; BLL.Order order = new Order(); order.LoadByPrimaryKey(orderID); if (!order.IsColumnNull("OrderTypeID")) { orderTypeID = Convert.ToInt32(ord.GetColumn("OrderTypeID")); } string transferDetail = ""; if (orderTypeID.HasValue) { BLL.Transfer transfer = new Transfer(); if (orderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER) { transfer.LoadByOrderID(orderID); PhysicalStore toStore = new PhysicalStore(); toStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID); BLL.Warehouse toWarehouse = new BLL.Warehouse(); toWarehouse.LoadByPrimaryKey(toStore.PhysicalStoreTypeID); transferType = "Store to Store Transfer"; stvSentTo = toWarehouse.Name; } if (orderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { transfer.LoadByOrderID(orderID); Activity fromActivity = new Activity(); fromActivity.LoadByPrimaryKey(transfer.FromStoreID); Activity toActivity = new Activity(); toActivity.LoadByPrimaryKey(transfer.ToStoreID); transferType = "Account to Account Transfer"; transferDetail = string.Format("From: {0} To: {1}", fromActivity.FullActivityName, toActivity.FullActivityName); } } if (!deliveryNote) { if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { return(WorkflowReportFactory.CreateModel22(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType)); } var stvReport = WorkflowReportFactory.CreateSTVonHeadedPaper(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType); if (transferDetail != "") { stvReport.TransferDetails.Text = transferDetail; stvReport.TransferDetails.Visible = true; } else { stvReport.TransferDetails.Visible = false; } return(stvReport); } else { return(WorkflowReportFactory.CreateDeliveryNote(ord, dvPriced, stvSentTo, pl.ID, null, false, true, hasInsurance, transferType)); } }
/// <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); }
/// <summary> /// Handles the Click event of the btnConfirmIssue control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> /// <exception cref="System.Exception"></exception> private void btnConfirmIssue_Click(object sender, EventArgs e) { // This is where the Issue is actually recorded and the stv is printed. // Do all kinds of validations. XtraReport STVReport = null; XtraReport DeliveryNoteReport = null; btnConfirmIssue1.Enabled = false; if (!IssueValid()) { XtraMessageBox.Show("Please Correct the Items Marked in Red before Proceeding with Issue", "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error); btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement); return; } if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DateTimePickerEx dtDate = ConvertDate.GetCurrentEthiopianDateText(); DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); // The User is now sure that the STV has to be printed and that // the order is also good to save. // This is the section that does the saving. BLL.Order order = new Order(); order.LoadByPrimaryKey(_orderID); // what are the pick lists, do we have devliery notes too? DataView dv = _dvOutstandingPickList; DataTable dvUnpriced = new DataTable(); DataTable dvPriced = dv.ToTable(); if (BLL.Settings.HandleGRV) { if (BLL.Settings.IsCenter) { dv.RowFilter = "(Cost is null or Cost=0)"; } else { dv.RowFilter = "DeliveryNote = true and (Cost is null or Cost=0)"; } dvUnpriced = dv.ToTable(); dv.RowFilter = "Cost is not null and Cost <> 0"; dvPriced = dv.ToTable(); } else { dvPriced = dv.ToTable(); } string stvPrinterName = ""; string deliveryNotePrinter = ""; if (!ConfirmPrinterSettings(dvPriced, dvUnpriced, out stvPrinterName, out deliveryNotePrinter)) { return; } bool saveSuccessful = false; MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { if (dvPriced.Rows.Count == 0 && dvUnpriced.Rows.Count == 0) { throw new Exception("The Items doesn’t meet the requirement: please check the price status for non-delivery notes!"); } mgr.BeginTransaction(); if (dvPriced.Rows.Count > 0) { STVReport = SaveAndPrintSTV(dvPriced.DefaultView, false, stvPrinterName, dtDate, dtCurrent); } if (dvUnpriced.Rows.Count > 0) { DeliveryNoteReport = SaveAndPrintSTV(dvUnpriced.DefaultView, true, deliveryNotePrinter, dtDate, dtCurrent); } var ordr = new Order(); ordr.LoadByPrimaryKey(_orderID); if (!ordr.IsColumnNull("OrderTypeID") && (ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER || ordr.OrderTypeID == BLL.OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)) { var transfer = new Transfer(); DateTime convertedEthDate = ConvertDate.DateConverter(dtDate.Text); transfer.CommitAccountToAccountTransfer(ordr.ID, CurrentContext.UserId, convertedEthDate); } mgr.CommitTransaction(); saveSuccessful = true; } catch (Exception exp) { mgr.RollbackTransaction(); //Removed the reset logic //MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgrReset(); XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ErrorHandler.Handle(exp); saveSuccessful = false; } if (saveSuccessful) { if (STVReport != null) { if (InstitutionIType.IsVaccine(GeneralInfo.Current)) { for (int i = 0; i < BLL.Settings.STVCopies; i++) { STVReport.Print(stvPrinterName); } } else { STVReport.Print(stvPrinterName); } } if (DeliveryNoteReport != null) { DeliveryNoteReport.Print(deliveryNotePrinter); } XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement); BindOutstandingPicklists(); gridOutstandingPicklistDetail.DataSource = null; PalletLocation.GarbageCollection(); if (BLL.Settings.AllowOnlineOrders) { Helpers.RRFServiceIntegration.SubmitOnlineIssue(_orderID); } } }