Beispiel #1
0
        private void OnConfirmClicked(object sender, EventArgs e)
        {
            printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                XtraMessageBox.Show("Print has been Canceled By User");
                return;
            }
            if (BLL.Settings.IsCenter)
            {
                GRV = new CenterCostCalculator();
                GRV.LoadGRV(ReceiptID);
                GRV.CalculateFinalCost();
            }
            else
            {
                GRV = new CostCalculator();
                GRV.LoadGRV(ReceiptID);
                (GRV as CostCalculator).LoadGRVPreviousStock();
                GRV.CalculateFinalCost();
            }
            if (!SetSellingPrice(GRV))
            {
                return;
            }

            HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);
            MyGeneration.dOOdads.TransactionMgr transaction            = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
            try
            {
                transaction.BeginTransaction();
                // This is where we set the Price for the previous Stock
                foreach (CostElement costElement in GRV.CostElements)
                {
                    costElement.PreviousCostDetials.Confirm(CurrentContext.UserId);
                }
                printout = PrintConfirmation(null);
                CostingService.ConfirmPriceChange(GRV.CostElements, CurrentContext.UserId, ChangeMode.Recieve, ReceiptID.ToString());
                GRV.SetFinalCostlog(CurrentContext.UserId);
                transaction.CommitTransaction();
            }
            catch (Exception ex)
            {
                transaction.RollbackTransaction();

                XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
            printout.Print(printDialog.PrinterSettings.PrinterName);
        }
        private void PrintReceiptConfirmation(string referenceNumber, int? reprintOfReceiptConfirmationPrintoutID)
        {
            ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout();
            HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);

            HCMIS.Desktop.Reports.SRMPrintout srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(CurrentContext.LoggedInUserName);

            int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
            BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
            //  receiveDoc.LoadByReferenceNo(reference);
            receiveDoc.LoadByReceiptID(ReceiptID);
            BLL.Supplier supplier = new Supplier();
            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);

            int printedID = 0;
            int GRNFNo = BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID);
            if (currentMode == Modes.DeliveryNotePrinting)
            {

                printout.BranchName.Text = GeneralInfo.Current.HospitalName;

                printout.xrGRVLabel.Text = "Delivery Note.";
                printout.xrAir.Visible = false;
                printout.xrAirValue.Visible = false;
                printout.xrTransit.Visible = false;
                printout.xrTransitValue.Visible = false;
                printout.xrInsurance.Visible = false;
                printout.xrInsuranceValue.Visible = false;
                printout.xrNumberOfCases.Visible = false;
                printout.xrNumberOfCasesValue.Visible = false;
                printout.xrInvoiceNo.Visible = false;

                printout.xrInvoiceNoValue.Visible = false;
                printout.xrPurchaseOrderNo.Visible = false;
                printout.xrPurchaseOrderNoValue.Visible = false;

                printout.xrSTV.Visible = false;
                printout.xrSTVNoValue.Visible = false;

                printout.DataSource = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 5, null, reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);

                CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                //dtDate.CustomFormat = "dd/MM/yyyy";
                dtDate.Value = receiveDoc.EurDate;

                printout.Date.Text = dtDate.Text;
            }

            var activity = new Activity();
            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            printout.xrLabelStoreName.Text = activity.FullActivityName;

            if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
            {
                HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage =
                    PrintReceiptConfirmationForShortage(referenceNumber, printedID);

                printout.xrShortageReport.ReportSource = printoutShortage;

                printout.PrintingSystem.ContinuousPageNumbering = true;
            }
            else
            {
               printout.ReportFooter.Visible = false;
            }

            //Successfully printed

            //Release Product
            CostCalculator GRV = new CostCalculator();
            GRV.LoadGRV(ReceiptID);
            GRV.ReleaseForIssue();

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();
            BLL.ReceiveDoc recDoc = new ReceiveDoc();
            recDoc.LoadByReferenceNo(reference);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BindFormContents();
        }
        private HCMIS.Desktop.Reports.ReceiptConfirmationPrintout PrintReceiptConfirmation(int ReceiptID, int? reprintOfReceiptConfirmationPrintoutID)
        {
            ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout();

            HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);

            BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
            //  receiveDoc.LoadByReferenceNo(reference);
            receiveDoc.LoadByReceiptID(ReceiptID);
            var activity = new Activity();
            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            BLL.Supplier supplier = new Supplier();
            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);
            BLL.Receipt receipt=new BLL.Receipt();
            receipt.LoadByPrimaryKey(receiveDoc.ReceiptID);
            BLL.ReceiptInvoice receiptInvoice= new ReceiptInvoice();
            receiptInvoice.LoadByPrimaryKey(receipt.ReceiptInvoiceID);
            BLL.PO po = new PO();
            po.LoadByPrimaryKey(receiptInvoice.POID);
            BLL.POType poType = new POType();
            poType.LoadByPrimaryKey(po.PurchaseType);

            int printedID = 0;
            string GRNFNo = FiscalYear.Current.GetCode(BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID));
            if (currentMode == Modes.GRVPrinting) //The GRVConfirmation is for reprinting
            {
                printout.BranchName.Text = GeneralInfo.Current.HospitalName;
                PrepareGRVPrintout(printout);
                //  String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

                if (poType.PurchaseOrderTypeCode == "LP") printout.xrGRVLabel.Text = "GRV No.";
                else printout.xrGRVLabel.Text = "iGRV No.";

                if (supplier.SupplierTypeID == SupplierType.CONSTANTS.HOME_OFFICE ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.HUBS ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.ACCOUNTS ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.STORES)
                {
                    //printout.xrGRVLabel.Text =  "iGRV No.";
                    printout.xrAir.Visible = false;
                    printout.xrAirValue.Visible = false;
                    printout.xrTransit.Visible = false;
                    printout.xrTransitValue.Visible = false;
                    printout.xrInsurance.Visible = false;
                    printout.xrInsuranceValue.Visible = false;
                    printout.xrNumberOfCases.Visible = false;
                    printout.xrNumberOfCasesValue.Visible = false;
                    printout.xrInvoiceNo.Text = "STV No.";
                    printout.xrPurchaseOrderNo.Visible = false;
                    printout.xrPurchaseOrderNoValue.Visible = false;

                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.xrSTV.Visible = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 4,
                                                                    null,reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
                    printout.DataSource = rc.DefaultView.ToTable();
                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
                else
                {
                   // printout.xrGRVLabel.Text = "GRV No.";
                    printout.xrSTV.Visible = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 2,
                                                                    null, reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.DataSource = rc.DefaultView.ToTable();

                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
            }

            printout.xrLabelStoreName.Text = activity.FullActivityName;

            if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
            {
                HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage =
                    PrintReceiptConfirmationForShortage(ReceiptID, printedID);
                if (currentMode == Modes.GRVPrinting)
                    PrepareGRVPrintout(printoutShortage);
                printout.xrShortageReport.ReportSource = printoutShortage;

                printout.PrintingSystem.ContinuousPageNumbering = true;
            }
            else
            {
                printout.ReportFooter.Visible = false;
            }

            //Release Product
            CostCalculator GRV = new CostCalculator();
            GRV.LoadGRV(ReceiptID);

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

            BLL.ReceiveDoc recDoc = new ReceiveDoc();
            recDoc.LoadByReceiptID(ReceiptID);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BLL.Receipt receiptStatus = new BLL.Receipt();
            receiptStatus.LoadByPrimaryKey(ReceiptID);
            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed");

            BindFormContents();
            // LOG Cost Analysis printout in PDF Log
            MemoryStream stream = new MemoryStream();
            printout.ExportToPdf(stream);
            HCMIS.Core.Distribution.Services.PrintLogService.SavePrintLogNoWait(stream, "GRV/IGRV", true, ReceiptID, CurrentContext.UserId, BLL.DateTimeHelper.ServerDateTime);
            return printout;
        }
        private void OnConfirmClicked(object sender, EventArgs e)
        {
            printDialog = new PrintDialog();

                if (printDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
               {
                   XtraMessageBox.Show("Print has been Canceled By User");
                   return;
               }
                if (BLL.Settings.IsCenter)
                {
                    GRV = new CenterCostCalculator();
                    GRV.LoadGRV(ReceiptID);
                    GRV.CalculateFinalCost();
                }
                else
                {
                    GRV = new CostCalculator();
                    GRV.LoadGRV(ReceiptID);
                    (GRV as CostCalculator).LoadGRVPreviousStock();
                    GRV.CalculateFinalCost();
                }
                if(!SetSellingPrice(GRV))
                {
                    return;
                }

                HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);
                MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                  transaction.BeginTransaction();
                  // This is where we set the Price for the previous Stock
                  foreach (CostElement costElement in GRV.CostElements)
                  {
                          costElement.PreviousCostDetials.Confirm(CurrentContext.UserId);
                  }
                    printout = PrintConfirmation(null);
                    CostingService.ConfirmPriceChange(GRV.CostElements, CurrentContext.UserId, ChangeMode.Recieve, ReceiptID.ToString());
                    GRV.SetFinalCostlog(CurrentContext.UserId);
                    transaction.CommitTransaction();
                }
                catch (Exception ex)
                {
                    transaction.RollbackTransaction();

                    XtraMessageBox.Show(ex.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    throw ;
                }
                printout.Print(printDialog.PrinterSettings.PrinterName);
        }
        public static XtraReport PrintReceiptConfirmation(string printedBy, int receiptID, int?previousReceiptConfirmationPrintoutID, bool forExporting, FiscalYear fiscalYear)
        {
            var rcPrevious       = new BLL.ReceiptConfirmationPrintout();
            int?idToBePrintedOut = null;

            if (forExporting && previousReceiptConfirmationPrintoutID.HasValue)
            {
                rcPrevious.LoadByPrimaryKey(previousReceiptConfirmationPrintoutID.Value);
                idToBePrintedOut = rcPrevious.IDPrinted;
            }

            var rc       = new BLL.ReceiptConfirmationPrintout();
            var printout =
                new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(printedBy);

            var srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(printedBy);

            var receiveDoc = new ReceiveDoc();
            var receipt    = new BLL.Receipt();

            receipt.LoadByPrimaryKey(receiptID);
            receiveDoc.LoadByReceiptID(receiptID);

            var referenceNumber = receiveDoc.RefNo;
            var activity        = new Activity();

            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            var supplier = new Supplier();

            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);
            int printedID = 0;

            string GRNFNo = fiscalYear.GetCode(BLL.ReceiptConfirmationPrintout.GetGRNFNo(receiptID));

            if (receipt.ReceiptTypeID == ReceiptType.CONSTANTS.STANDARD_RECEIPT || receipt.ReceiptTypeID == ReceiptType.CONSTANTS.DELIVERY_NOTE || receipt.ReceiptTypeID == ReceiptType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
            {
                if (!String.IsNullOrEmpty(GeneralInfo.Current.HospitalName))
                {
                    printout.BranchName.Text = GeneralInfo.Current.HospitalName;
                }
                else
                {
                    throw new Exception("Branch name could not be read from the database.");
                }

                PrepareGRVPrintout(printout);
                //  String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

                if (supplier.SupplierTypeID == SupplierType.CONSTANTS.HOME_OFFICE ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.HUBS ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.ACCOUNTS ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.STORES)
                {
                    printout.xrGRVLabel.Text                = "iGRV No.";
                    printout.xrAir.Visible                  = false;
                    printout.xrAirValue.Visible             = false;
                    printout.xrTransit.Visible              = false;
                    printout.xrTransitValue.Visible         = false;
                    printout.xrInsurance.Visible            = false;
                    printout.xrInsuranceValue.Visible       = false;
                    printout.xrNumberOfCases.Visible        = false;
                    printout.xrNumberOfCasesValue.Visible   = false;
                    printout.xrInvoiceNo.Text               = "STV No.";
                    printout.xrPurchaseOrderNo.Visible      = false;
                    printout.xrPurchaseOrderNoValue.Visible = false;

                    printout.xrLabelGRNF.Text     = GRNFNo;
                    printout.xrSTV.Visible        = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 4,
                                                          idToBePrintedOut, previousReceiptConfirmationPrintoutID, fiscalYear);
                    printout.DataSource = rc.DefaultView.ToTable();
                    var dtDate = new DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
                else
                {
                    printout.xrGRVLabel.Text      = "GRV No.";
                    printout.xrSTV.Visible        = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 2,
                                                          idToBePrintedOut, previousReceiptConfirmationPrintoutID, fiscalYear);
                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.DataSource       = rc.DefaultView.ToTable();

                    var dtDate = new DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }


                printout.xrLabelStoreName.Text = activity.FullActivityName;

                if (ReceiveDoc.IsThereShortageOrDamage(receiptID))
                {
                    ReceiptConfirmationShortagePrintout printoutShortage =
                        PrintReceiptConfirmationForShortage(receiptID, printedID, fiscalYear);

                    PrepareGRVPrintout(printoutShortage);
                    printout.xrShortageReport.ReportSource = printoutShortage;

                    printout.PrintingSystem.ContinuousPageNumbering = true;
                }
                else
                {
                    printout.ReportFooter.Visible = false;
                }
                if (!forExporting) //If this is not for exporting, we print on paper.
                {
                    if (printout.PrintDialog() != DialogResult.OK)
                    {
                        throw new Exception("Print cancelled by user!");
                    }
                }

                return(printout);
            }

            else if (receipt.ReceiptTypeID == ReceiptType.CONSTANTS.STOCK_RETURN)
            {
                if (!String.IsNullOrEmpty(GeneralInfo.Current.HospitalName))
                {
                    srmPrintout.BranchName.Text = GeneralInfo.Current.HospitalName;
                }

                rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 3, idToBePrintedOut,
                                          previousReceiptConfirmationPrintoutID, fiscalYear);
                srmPrintout.DataSource = rc.DefaultView.ToTable();

                var rUnit = new Institution();
                var idoc  = new IssueDoc();
                if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
                {
                    idoc.LoadByPrimaryKey(receiveDoc.ReturnedFromIssueDocID);
                    rUnit.LoadByPrimaryKey(idoc.ReceivingUnitID);
                }
                else
                {
                    var po = new PO();
                    po.LoadByReceiptID(receiveDoc.ReceiptID);
                    rUnit.LoadByPrimaryKey(int.Parse(po.RefNo));
                }

                srmPrintout.xrFromValue.Text   = rUnit.Name;
                srmPrintout.xrWoredaValue.Text = rUnit.WoredaText;
                srmPrintout.xrRegionValue.Text = rUnit.Region;
                srmPrintout.xrZoneValue.Text   = rUnit.ZoneText;

                if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
                {
                    var stvLog = new Issue();
                    stvLog.LoadByPrimaryKey(idoc.STVID);
                    var issuedActivity = new Activity();
                    issuedActivity.LoadByPrimaryKey(idoc.StoreId);
                    srmPrintout.xrAccountName.Text = issuedActivity.FullActivityName;
                    srmPrintout.xrSTVNoValue.Text  = stvLog.IDPrinted.ToString("00000");
                }
                else
                {
                    srmPrintout.xrAccountName.Text = activity.FullActivityName;;
                    srmPrintout.xrSTVNoValue.Text  = receiveDoc.RefNo;
                }

                var dtDate = new DateTimePickerEx();
                dtDate.Value          = receiveDoc.EurDate;
                srmPrintout.Date.Text = dtDate.Text;

                if (!forExporting)
                {
                    if (srmPrintout.PrintDialog() != DialogResult.OK)
                    {
                        throw new Exception("Print cancelled by user!");
                    }
                }
                return(srmPrintout);
            }

            else //TODO: Implement Delivery notes.
            {
                return(null);
            }
        }
        private void PrintReceiptConfirmation(string referenceNumber, int?reprintOfReceiptConfirmationPrintoutID)
        {
            ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout();

            HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);

            HCMIS.Desktop.Reports.SRMPrintout srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(CurrentContext.LoggedInUserName);

            int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);

            BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
            //  receiveDoc.LoadByReferenceNo(reference);
            receiveDoc.LoadByReceiptID(ReceiptID);
            BLL.Supplier supplier = new Supplier();
            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);

            int printedID = 0;
            int GRNFNo    = BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID);

            if (currentMode == Modes.DeliveryNotePrinting)
            {
                printout.BranchName.Text = GeneralInfo.Current.HospitalName;

                printout.xrGRVLabel.Text              = "Delivery Note.";
                printout.xrAir.Visible                = false;
                printout.xrAirValue.Visible           = false;
                printout.xrTransit.Visible            = false;
                printout.xrTransitValue.Visible       = false;
                printout.xrInsurance.Visible          = false;
                printout.xrInsuranceValue.Visible     = false;
                printout.xrNumberOfCases.Visible      = false;
                printout.xrNumberOfCasesValue.Visible = false;
                printout.xrInvoiceNo.Visible          = false;

                printout.xrInvoiceNoValue.Visible       = false;
                printout.xrPurchaseOrderNo.Visible      = false;
                printout.xrPurchaseOrderNoValue.Visible = false;


                printout.xrSTV.Visible        = false;
                printout.xrSTVNoValue.Visible = false;

                printout.DataSource = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 5, null, reprintOfReceiptConfirmationPrintoutID, FiscalYear.Current);

                CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                //dtDate.CustomFormat = "dd/MM/yyyy";
                dtDate.Value = receiveDoc.EurDate;

                printout.Date.Text = dtDate.Text;
            }

            var activity = new Activity();

            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            printout.xrLabelStoreName.Text = activity.FullActivityName;

            if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
            {
                HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage =
                    PrintReceiptConfirmationForShortage(referenceNumber, printedID);


                printout.xrShortageReport.ReportSource = printoutShortage;

                printout.PrintingSystem.ContinuousPageNumbering = true;
            }
            else
            {
                printout.ReportFooter.Visible = false;
            }


            //Successfully printed

            //Release Product
            CostCalculator GRV = new CostCalculator();

            GRV.LoadGRV(ReceiptID);
            GRV.ReleaseForIssue();

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

            BLL.ReceiveDoc recDoc = new ReceiveDoc();
            recDoc.LoadByReferenceNo(reference);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BindFormContents();
        }
Beispiel #7
0
        private HCMIS.Desktop.Reports.ReceiptConfirmationPrintout PrintReceiptConfirmation(int ReceiptID, int?reprintOfReceiptConfirmationPrintoutID)
        {
            ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout();

            HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);



            BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
            //  receiveDoc.LoadByReferenceNo(reference);
            receiveDoc.LoadByReceiptID(ReceiptID);
            var activity = new Activity();

            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            BLL.Supplier supplier = new Supplier();
            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);
            BLL.Receipt receipt = new BLL.Receipt();
            receipt.LoadByPrimaryKey(receiveDoc.ReceiptID);
            BLL.ReceiptInvoice receiptInvoice = new ReceiptInvoice();
            receiptInvoice.LoadByPrimaryKey(receipt.ReceiptInvoiceID);
            BLL.PO po = new PO();
            po.LoadByPrimaryKey(receiptInvoice.POID);
            BLL.POType poType = new POType();
            poType.LoadByPrimaryKey(po.PurchaseType);

            int    printedID = 0;
            string GRNFNo    = FiscalYear.Current.GetCode(BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID));

            if (currentMode == Modes.GRVPrinting) //The GRVConfirmation is for reprinting
            {
                printout.BranchName.Text = GeneralInfo.Current.HospitalName;
                PrepareGRVPrintout(printout);
                //  String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

                if (poType.PurchaseOrderTypeCode == "LP")
                {
                    printout.xrGRVLabel.Text = "GRV No.";
                }
                else
                {
                    printout.xrGRVLabel.Text = "iGRV No.";
                }

                if (supplier.SupplierTypeID == SupplierType.CONSTANTS.HOME_OFFICE ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.HUBS ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.ACCOUNTS ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.STORES)
                {
                    //printout.xrGRVLabel.Text =  "iGRV No.";
                    printout.xrAir.Visible                  = false;
                    printout.xrAirValue.Visible             = false;
                    printout.xrTransit.Visible              = false;
                    printout.xrTransitValue.Visible         = false;
                    printout.xrInsurance.Visible            = false;
                    printout.xrInsuranceValue.Visible       = false;
                    printout.xrNumberOfCases.Visible        = false;
                    printout.xrNumberOfCasesValue.Visible   = false;
                    printout.xrInvoiceNo.Text               = "STV No.";
                    printout.xrPurchaseOrderNo.Visible      = false;
                    printout.xrPurchaseOrderNoValue.Visible = false;

                    printout.xrLabelGRNF.Text     = GRNFNo;
                    printout.xrSTV.Visible        = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 4,
                                                          null, reprintOfReceiptConfirmationPrintoutID, FiscalYear.Current);
                    printout.DataSource = rc.DefaultView.ToTable();
                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
                else
                {
                    // printout.xrGRVLabel.Text = "GRV No.";
                    printout.xrSTV.Visible        = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 2,
                                                          null, reprintOfReceiptConfirmationPrintoutID, FiscalYear.Current);
                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.DataSource       = rc.DefaultView.ToTable();

                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
            }


            printout.xrLabelStoreName.Text = activity.FullActivityName;

            if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
            {
                HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage =
                    PrintReceiptConfirmationForShortage(ReceiptID, printedID);
                if (currentMode == Modes.GRVPrinting)
                {
                    PrepareGRVPrintout(printoutShortage);
                }
                printout.xrShortageReport.ReportSource = printoutShortage;

                printout.PrintingSystem.ContinuousPageNumbering = true;
            }
            else
            {
                printout.ReportFooter.Visible = false;
            }

            //Release Product
            CostCalculator GRV = new CostCalculator();

            GRV.LoadGRV(ReceiptID);

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

            BLL.ReceiveDoc recDoc = new ReceiveDoc();
            recDoc.LoadByReceiptID(ReceiptID);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BLL.Receipt receiptStatus = new BLL.Receipt();
            receiptStatus.LoadByPrimaryKey(ReceiptID);
            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed");

            BindFormContents();
            // LOG Cost Analysis printout in PDF Log
            MemoryStream stream = new MemoryStream();

            printout.ExportToPdf(stream);
            HCMIS.Core.Distribution.Services.PrintLogService.SavePrintLogNoWait(stream, "GRV/IGRV", true, ReceiptID, CurrentContext.UserId, BLL.DateTimeHelper.ServerDateTime);
            return(printout);
        }