Exemplo n.º 1
0
 public static PickingSlip CreatePickingSlip(int ID, string pickingNo, global::System.DateTime pickingDate, int pickingSlip_TransportRoute, string truckLicense, double truckCapacityWeight, double totalWeight, bool status, byte[] rowVersion)
 {
     PickingSlip pickingSlip = new PickingSlip();
     pickingSlip.Id = ID;
     pickingSlip.PickingNo = pickingNo;
     pickingSlip.PickingDate = pickingDate;
     pickingSlip.PickingSlip_TransportRoute = pickingSlip_TransportRoute;
     pickingSlip.TruckLicense = truckLicense;
     pickingSlip.TruckCapacityWeight = truckCapacityWeight;
     pickingSlip.TotalWeight = totalWeight;
     pickingSlip.Status = status;
     pickingSlip.RowVersion = rowVersion;
     return pickingSlip;
 }
Exemplo n.º 2
0
 public void AddToPickingSlips(PickingSlip pickingSlip)
 {
     base.AddObject("PickingSlips", pickingSlip);
 }
        private void printButton_Click(object sender, EventArgs e)
        {
            // Have extra enumeration to go ProKnow with only ONE call
            List <CustomerProductDataVO> productObjects = new List <CustomerProductDataVO>();
            List <String> customerNames = new List <String>();

            List <int> tickets = new List <int>(gvLoans.Rows.Count);

            Cursor = Cursors.WaitCursor;
            try
            {
                // improve efficiency -- only return new numbers if these have been previously loaded
                foreach (DataGridViewRow myRow in gvLoans.Rows)
                {
                    if (Convert.ToBoolean(myRow.Cells[colSelect.Name].Value) &&
                        !myRow.Cells[colSelect.Name].ReadOnly)
                    {
                        int iTktNumber =
                            Utilities.GetIntegerValue(myRow.Cells[colNumber.Name].Value, 0);

                        if (iTktNumber != 0)
                        {
                            tickets.Add(iTktNumber);
                        }
                    }
                }

                string   errorCode;
                string   errorTxt;
                DateTime dt = Convert.ToDateTime(dateCalendarSearchDate.SelectedDate);

                StoreLoans.Get_PFI_Details(CashlinxDesktopSession.Instance.CurrentSiteId.StoreNumber, dt,
                                           tickets, out _PawnLoans, out _PawnApplications, out _CustomerVOs,
                                           out _Purchases, out errorCode, out errorTxt);

                foreach (DataGridViewRow myRow in gvLoans.Rows)
                {
                    if (Convert.ToBoolean(myRow.Cells[colSelect.Name].Value) &&
                        !myRow.Cells[colSelect.Name].ReadOnly)
                    {
                        int iTktNumber =
                            Utilities.GetIntegerValue(myRow.Cells[colNumber.Name].Value, 0);

                        string   customer = (string)myRow.Cells[4].Value;
                        PawnLoan pawnLoan = null;

                        if (myRow.Cells[colType.Name].Value.Equals("LOAN"))
                        {
                            if (_PawnLoans != null)
                            {
                                pawnLoan = (from ploan in _PawnLoans
                                            where
                                            ploan.TicketNumber == iTktNumber &&
                                            ploan.ProductType == ProductType.PAWN.ToString()
                                            select ploan).FirstOrDefault();
                            }

                            if (pawnLoan != null)
                            {
                                LoanPrinted loanPrinted =
                                    _PrintedLoans.Find(
                                        l => l.LoanNumber == iTktNumber && l.RefType == 1);
                                loanPrinted.bPrinted = true;
                                _PrintedLoans.RemoveAll(
                                    l => l.LoanNumber == iTktNumber && l.RefType == 1);
                                _PrintedLoans.Add(loanPrinted);
                                productObjects.Add(pawnLoan);
                                customerNames.Add(customer);
                            }
                        }
                        else
                        {
                            PurchaseVO purchaseObj = null;
                            if (_Purchases != null)
                            {
                                purchaseObj = (from purchase in _Purchases where purchase.TicketNumber == iTktNumber select purchase).FirstOrDefault();
                            }
                            if (purchaseObj != null)
                            {
                                LoanPrinted loanPrinted =
                                    _PrintedLoans.Find(l => l.LoanNumber == iTktNumber && l.RefType == 2);
                                loanPrinted.bPrinted = true;
                                _PrintedLoans.RemoveAll(l => l.LoanNumber == iTktNumber && l.RefType == 2);
                                _PrintedLoans.Add(loanPrinted);
                                productObjects.Add(purchaseObj);
                                customerNames.Add(customer);
                            }
                        }
                    }
                }
                if (productObjects.Count() > 0)
                {
                    ProcessingMessage processingForm = new ProcessingMessage("Please wait while we generate report.");
                    try
                    {
                        processingForm.Show();

                        this.Cursor = Cursors.WaitCursor;

                        //----- Tracy 12/15/2010
                        List <int>    lstTicketNumbers = new List <int>();
                        List <string> lstRefTypes      = new List <string>();
                        string        sErrorCode;
                        string        sErrorText;

                        foreach (CustomerProductDataVO o in productObjects)
                        {
                            lstTicketNumbers.Add(o.TicketNumber);
                            lstRefTypes.Add(o.ProductType == "PAWN" ? "1" : "2");
                        }

                        if (lstTicketNumbers.Count > 0 && !StoreLoans.UpdateTempStatus(
                                lstTicketNumbers,
                                StateStatus.PFIW,
                                CashlinxDesktopSession.Instance.CurrentSiteId.StoreNumber,
                                true,
                                lstRefTypes,
                                out sErrorCode,
                                out sErrorText))
                        {
                            MessageBox.Show("Error updating PFI Verify.  " + sErrorText, "PFI Verification Update", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        //------- Tracy 12/15/2010

                        var context      = new PickingSlipHelper().GetPickingSlipReportContext(productObjects, customerNames, true);
                        var reportObject = new ReportObject();
                        reportObject.ReportTempFile = SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath;
                        reportObject.CreateTemporaryFullName();
                        context.ReportObject = reportObject;
                        var pickingSlip = new PickingSlip(context);

                        if (!pickingSlip.CreateReport())
                        {
                            processingForm.Close();
                            processingForm.Dispose();
                            this.Cursor = Cursors.Default;
                            MessageBox.Show("Failed to generate report", "Picking Slip", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        //Dictionary<string, string> eDeviceData = new PrintUtilities().GetPrintDeviceData("pfipickslip");
                        if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled &&
                            GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid)
                        {
                            if (FileLogger.Instance.IsLogInfo)
                            {
                                FileLogger.Instance.logMessage(LogLevel.INFO, "PFI_SelectLoan", "Printing PFI picking slip on {0}",
                                                               GlobalDataAccessor.Instance.DesktopSession.LaserPrinter);
                            }
                            string strReturnMessage =
                                PrintingUtilities.printDocument(reportObject.ReportTempFileFullName,
                                                                GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress,
                                                                GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 1);
                            if (!strReturnMessage.Contains("SUCCESS"))
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot print picking slip : " + strReturnMessage);
                            }
                        }

                        processingForm.Close();
                        processingForm.Dispose();
                        this.Cursor = Cursors.Default;

                        MessageBox.Show("Printing Complete", "Picking Slip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception exc)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this, exc.Message);
                        processingForm.Close();
                        processingForm.Dispose();
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(exc.Message);
                    }
                }
                //else
                //{
                //    continueButton.Enabled = false;
                //}
                continueButton.Enabled = true;
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error in printing.  Retry. (" + exp.Message + ")", "PFI Printing");
            }

            Cursor = Cursors.Default;
        }