/// <summary>
        /// Gets the picked items on STV.
        /// </summary>
        /// <param name="stvlogID">The stvlog ID.</param>
        /// <returns></returns>
        public static DataView GetPickedItemsOnSTV(int stvlogID, bool includeDeleted)
        {
            Issue stvLog = new Issue();
            stvLog.LoadByPrimaryKey(stvlogID);

            PickList pickList = new PickList();
            pickList.LoadByPrimaryKey(stvLog.PickListID);

            DataView dv = pickList.GetPickedOrderDetailForOrder(stvlogID, includeDeleted);
            dv.RowFilter = "STVID = " + stvlogID;
            return dv;
        }
Example #2
0
        /// <summary>
        /// Gets the picked items on STV.
        /// </summary>
        /// <param name="stvlogID">The stvlog ID.</param>
        /// <returns></returns>
        public static DataView GetPickedItemsOnSTV(int stvlogID, bool includeDeleted)
        {
            Issue stvLog = new Issue();

            stvLog.LoadByPrimaryKey(stvlogID);

            PickList pickList = new PickList();

            pickList.LoadByPrimaryKey(stvLog.PickListID);

            DataView dv = pickList.GetPickedOrderDetailForOrder(stvlogID, includeDeleted);

            dv.RowFilter = "STVID = " + stvlogID;
            return(dv);
        }
        /// <summary>
        /// Handles the Click event of the btnReprint control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void btnReprint_Click(object sender, EventArgs e)
        {
            var issue = new Issue();

            issue.LoadByPrimaryKey(_stvLogIdChosen.Value);
            if (!Validate(issue))
            {
                return;
            }

            var orderId = Convert.ToInt32(gridViewTransaction.GetFocusedDataRow()["OrderID"]);
            var pl      = new PickList();
            var dv      = pl.GetPickedOrderDetailForOrder(_stvLogIdChosen.Value, false);

            MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            XtraReport  xtraReport;
            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }


            try
            {
                mgr.BeginTransaction();

                xtraReport = RePrintSTV(dv, orderId, pl, _stvLogIdChosen, _isConvertedDn);

                mgr.CommitTransaction();
            }
            catch (Exception exception)
            {
                mgr.RollbackTransaction();
                XtraMessageBox.Show("Print Problem:" + exception.Message, "Print Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }

            if (xtraReport != null)
            {
                xtraReport.Print(printDialog.PrinterSettings.PrinterName);
            }

            FilterStvLog();
        }
        /// <summary>
        /// Handles the Click event of the btnReprint control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void btnReprint_Click(object sender, EventArgs e)
        {
            var issue = new Issue();
            issue.LoadByPrimaryKey(_stvLogIdChosen.Value);
            if (!Validate(issue))
                return;

            var orderId = Convert.ToInt32(gridViewTransaction.GetFocusedDataRow()["OrderID"]);
            var pl = new PickList();
            var dv = pl.GetPickedOrderDetailForOrder(_stvLogIdChosen.Value, false);
            MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            XtraReport xtraReport;
            PrintDialog printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            try
            {
                mgr.BeginTransaction();

                xtraReport = RePrintSTV(dv, orderId, pl, _stvLogIdChosen, _isConvertedDn);

                mgr.CommitTransaction();
            }
            catch (Exception exception)
            {
                mgr.RollbackTransaction();
                XtraMessageBox.Show("Print Problem:" + exception.Message, "Print Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }

            if (xtraReport != null)
            {
                xtraReport.Print(printDialog.PrinterSettings.PrinterName);
            }

            FilterStvLog();
        }
        /// <summary>
        /// Handles the Click event of the btnPrint control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void btnPrint_Click(object sender, EventArgs e)
        {
            DataRow dr = gridViewTransaction.GetFocusedDataRow();
            PickList pl = new PickList();
            PickListDetail pld = new PickListDetail();
            int orderId = Convert.ToInt32(dr["OrderID"]);
            DataView dv = pl.GetPickedOrderDetailForOrder(_stvLogIdChosen.Value, false);

            XtraReport xtraReport = RePrintSTV(dv, orderId, pl, _stvLogIdChosen, false, false);
            if (xtraReport != null)
            {
                xtraReport.PrintDialog();
            }
        }
        public static XtraReport CreateInvoice(int stvLogID)
        {
            BLL.Issue       stvLog = new Issue();
            BLL.PickList    pl     = new BLL.PickList();
            BLL.Order       order  = new Order();
            BLL.Institution rus    = new Institution();

            stvLog.LoadByPrimaryKey(stvLogID);
            if (stvLog.IsColumnNull("IsDeliveryNote"))
            {
                stvLog.IsDeliveryNote = false;
            }

            //this makes the assumption that the Insurance is not calculated
            if (stvLog.IsColumnNull("HasInsurance"))
            {
                stvLog.HasInsurance = false;
            }
            if (stvLog.IsColumnNull("IsVoided"))
            {
                stvLog.IsVoided = false;
            }


            pl.LoadByPrimaryKey(stvLog.PickListID);
            order.LoadByPrimaryKey(pl.OrderID);
            if (!order.IsColumnNull("RequestedBy"))
            {
                rus.LoadByPrimaryKey(order.RequestedBy);
            }


            var mode = new Mode();

            mode.LoadByPrimaryKey(order.FromStore);

            DataView dv = pl.GetPickedOrderDetailForOrder(stvLogID, stvLog.IsVoided);

            if (dv.Count == 0 && !stvLog.IsColumnNull("IsRePrintOf"))
            {
                dv = pl.GetPickedOrderDetailForOrder(stvLog.IsReprintOf, stvLog.IsVoided);
            }

            XtraReport report = null;

            if (order.PaymentTypeID == PaymentType.Constants.CASH)
            {
                report = CreateCashInvoice(order, dv.Table, rus, pl, stvLog.IsDeliveryNote, stvLog.HasInsurance,
                                           mode.TypeName, false, stvLogID);
            }
            if (order.PaymentTypeID == PaymentType.Constants.CREDIT)
            {
                report = CreateCreditInvoice(dv.Table, order, pl, rus, stvLog.IsDeliveryNote, stvLog.HasInsurance, mode.TypeName, false, stvLogID);
            }

            if (order.PaymentTypeID == PaymentType.Constants.STV)
            {
                //TODO: Fix this sent to.
                string sentTo = "";
                if (rus.RowCount > 0)
                {
                    sentTo = rus.Name;
                }

                if (!stvLog.IsDeliveryNote)
                {
                    report = CreateSTVonHeadedPaper(order, dv.Table, sentTo, stvLog.PickListID, stvLog.ID, false, false,
                                                    stvLog.HasInsurance, null);
                }
                else
                {
                    report = CreateDeliveryNote(order, dv.Table, sentTo, stvLog.PickListID, stvLog.ID, false, false,
                                                stvLog.HasInsurance, null);
                }
            }

            return(report);
        }