public static DateTime ConvertFromEthiopian(DateTime dt)
 {
     CalendarLib.DateTimePickerEx dtpkr = new CalendarLib.DateTimePickerEx();
     dtpkr.Text = dt.ToString();
     CalendarLib.EthiopianCalendar ec = new CalendarLib.EthiopianCalendar();
     return(dtpkr.Value);
 }
 public static DateTime ConvertFromEthiopian(DateTime dt)
 {
     CalendarLib.DateTimePickerEx dtpkr = new CalendarLib.DateTimePickerEx();
     dtpkr.Text = dt.ToString();
     CalendarLib.EthiopianCalendar ec = new CalendarLib.EthiopianCalendar();
     return dtpkr.Value;
 }
 public static int GetEthiopianYear(DateTime dt)
 {
     CalendarLib.DateTimePickerEx dtpkr = new CalendarLib.DateTimePickerEx();
     dtpkr.Value = dt;
     dtpkr.Format = System.Windows.Forms.DateTimePickerFormat.Short;
     DateTime edt = Convert.ToDateTime(dtpkr.Text);
     return edt.Year;
 }
        public static int GetEthiopianYear(DateTime dt)
        {
            CalendarLib.DateTimePickerEx dtpkr = new CalendarLib.DateTimePickerEx();
            dtpkr.Value  = dt;
            dtpkr.Format = System.Windows.Forms.DateTimePickerFormat.Short;
            DateTime edt = Convert.ToDateTime(dtpkr.Text);

            return(edt.Year);
        }
        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;
        }
        /// <summary>
        /// Prepare all lookups
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ManageItems_Load(object sender, EventArgs e)
        {
            var stor = new Stores();

            stor.GetActiveStores();
            cboStores.Properties.DataSource = stor.DefaultView;
            cboStores.ItemIndex             = 0;

            var rec   = new DisposalReasons();
            var dtDis = rec.GetAvailableReasons();

            cboReasons.Properties.DataSource = dtDis.DefaultView;
            reasonBindingSource.DataSource   = dtDis.DefaultView;
            // cboReasons.ItemIndex = 0;

            var itemunit = new ItemUnit();
            var units    = itemunit.GetAllUnits();

            unitbindingSource.DataSource = units.DefaultView;

            var unitcolumn = ((GridView)gridAdjustments.MainView).Columns[10];

            switch (VisibilitySetting.HandleUnits)
            {
            case 1:
                unitcolumn.Visible = false;
                break;

            case 2:
                unitcolumn.Visible = true;
                break;

            default:
                unitcolumn.Visible = true;
                break;
            }
            try
            {
                //CALENDAR:
                var dtDate = new CalendarLib.DateTimePickerEx
                {
                    CustomFormat = "MM/dd/yyyy",
                    Value        = DateTime.Now
                };
                var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode);
                if (dr == null)
                {
                    return;
                }

                var disp = new Disposal();
                if (dr["ParentID"] == DBNull.Value)
                {
                    var dt1 = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1);
                    var dt2 = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1);
                    dtRec           = disp.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dt1, dt2);
                    lblAdjDate.Text = dr["RefNo"].ToString();
                }
                else
                {
                    dtRec           = disp.GetDocumentByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString());
                    lblAdjDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy");
                }
                gridAdjustments.DataSource = dtRec;
            }
            catch (Exception ex)
            {
            }
        }
        /// <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 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 #10
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);
        }
        /// <summary>
        /// Prepare all lookups
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ManageItems_Load(object sender, EventArgs e)
        {
            var stor = new Stores();
            stor.GetActiveStores();
            cboStores.Properties.DataSource = stor.DefaultView;
            cboStores.ItemIndex = 0;

            var rec = new DisposalReasons();
            var dtDis = rec.GetAvailableReasons();
            cboReasons.Properties.DataSource = dtDis.DefaultView;
            reasonBindingSource.DataSource = dtDis.DefaultView;
               // cboReasons.ItemIndex = 0;

            var itemunit = new ItemUnit();
            var units = itemunit.GetAllUnits();
            unitbindingSource.DataSource = units.DefaultView;

            var unitcolumn = ((GridView)gridAdjustments.MainView).Columns[10];
            switch (VisibilitySetting.HandleUnits)
            {
                case 1:
                    unitcolumn.Visible = false;
                    break;
                case 2:
                    unitcolumn.Visible = true;
                    break;
                default:
                    unitcolumn.Visible = true;
                    break;
            }
             try
            {
                //CALENDAR:
                var dtDate = new CalendarLib.DateTimePickerEx
                {
                    CustomFormat = "MM/dd/yyyy",
                    Value = DateTime.Now
                };
                var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode);
                if (dr == null) return;

                var disp = new Disposal();
                if (dr["ParentID"] == DBNull.Value)
                {
                    var dt1 = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1);
                    var dt2 = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1);
                    dtRec = disp.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue),dt1,dt2);
                    lblAdjDate.Text = dr["RefNo"].ToString();
                }
                else
                {
                    dtRec = disp.GetDocumentByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString());
                    lblAdjDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy");
                }
                gridAdjustments.DataSource = dtRec;
            }
            catch (Exception ex)
            {

            }
        }