/// <summary>
 /// Formats the credit invoice.
 /// </summary>
 /// <param name="ord">The ord.</param>
 /// <param name="dvPriced">The dv priced.</param>
 /// <param name="rus">The rus.</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 FormatCreditInvoice_Smaller(DataTable dvPriced, Order ord, PickList pl, Institution rus, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService)
 {
     string activityName = txtConfirmFromStore.Text;
     bool hasInsurnance = chkIncludeInsurance.Checked;
     return WorkflowReportFactory.CreateCreditInvoiceSmaller(dvPriced, ord, pl, rus, deliveryNote, hasInsurnance, activityName);
 }
        /// <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>
        /// Formats the credit invoice.
        /// </summary>
        /// <param name="ord">The ord.</param>
        /// <param name="dvPriced">The dv priced.</param>
        /// <param name="rus">The rus.</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 FormatCreditInvoice(Order ord, DataTable dvPriced, BLL.Institution rus, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService)
        {
            if (BLL.Settings.UseSmallerCreditPrintout)
            {
                return FormatCreditInvoice_Smaller(dvPriced, ord, pl, rus, deliveryNote, printerName, pLogService);
            }

                return FormatCreditInvoice_Larger(dvPriced, ord, pl, rus, deliveryNote, printerName, pLogService);
        }
 /// <summary>
 /// Formats the cash invoice.
 /// </summary>
 /// <param name="ord">The ord.</param>
 /// <param name="dvPriced">The dv priced.</param>
 /// <param name="rus">The rus.</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 FormatCashInvoice_Larger(Order ord, DataTable dvPriced, BLL.Institution rus, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService)
 {
     string activityName = txtConfirmFromStore.Text;
     bool hasInsurnance = chkIncludeInsurance.Checked;
     return WorkflowReportFactory.CreateCashInvoice(ord, dvPriced, rus, pl, deliveryNote, hasInsurnance,
                                                             activityName, true, null);
 }
 private XtraReport FormatCreditRePrintInvoice_Smaller(DataTable dvPriced, Order ord, PickList pl, Institution rus, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int? stvLogID)
 {
     string activityName = "";
     bool hasInsurnance = includeInsurance;
     return WorkflowReportFactory.CreateCreditRePrintInvoiceSmaller(dvPriced, ord, pl, rus, deliveryNote, hasInsurnance, activityName, _stvLogIdChosen);
 }
 private XtraReport FormatCashRePrintInvoice_Larger(Order ord, DataTable dvPriced, BLL.Institution rus, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int? stvLogID)
 {
     string activityName = "";
     bool hasInsurnance = includeInsurance;
     return WorkflowReportFactory.CreateCashRePrintInvoiceLarger(ord, dvPriced, rus, pl, deliveryNote, hasInsurnance, activityName, true, _stvLogIdChosen);
 }
        private XtraReport FormatCashRePrintInvoice(Order ord, DataTable dvPriced, BLL.Institution rus, PickList pl, bool deliveryNote, string printerName, HCMIS.Core.Distribution.Services.PrintLogService pLogService, int? stvLogID)
        {
            if (BLL.Settings.UseSmallerCashPrintout)
            {
                return FormatCashRePrintInvoice_Smaller(ord, dvPriced, rus, pl, deliveryNote, printerName, pLogService, _stvLogIdChosen);
            }

            return FormatCashRePrintInvoice_Larger(ord, dvPriced, rus, pl, deliveryNote, printerName, pLogService, _stvLogIdChosen);
        }