コード例 #1
0
        private void buttonPrint_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(this,
                                                  "Do you want to Print\n"
                                                  + ((LSExtendedWarrenty.AppBase.Warranty)DataSource.Value)[0].WarrentyNumber
                                                  + "\nagain?", "Confirm Print",
                                                  MessageBoxButtons.YesNo);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                const string ReportPath = @"LSExtendedWarrenty.WarrentySlip.rdlc";

                String PrinterName = SettingsProvider.GetDefaultPrinter();
                using (ReportPriner Printer = new ReportPriner(ReportPath, DataSource, ReportParameter))
                {
                    Printer.Run(PrinterName);
                }
            }
            this.Close();
        }
コード例 #2
0
        private void buttonPrint_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;

            string receipt = textBoxReceipt.Text.Trim();

            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

            builder.DataSource     = SettingsProvider.GetDataSource();
            builder.InitialCatalog = SettingsProvider.GetDatabase();
            builder.UserID         = SettingsProvider.GetUserName();
            builder.Password       = SettingsProvider.GetPassword();
            int                 type                = 2;
            int                 entryStatus         = 0;
            int                 transactionStatus   = 0;
            int                 defaultAddressType  = 0;
            Transaction         TransactionHeader   = new Transaction();
            TransactionCustomer TransactionCustomer = new TransactionCustomer();
            TransactionLines    TransactionLines    = new TransactionLines(null);

            using (var db = new DeliveryDbContext(builder.ConnectionString))
            {
                var transaction = from tra_h in db.RBOTRANSACTIONTABLE
                                  join sto in db.RBOSTORETABLE on tra_h.STORE equals sto.STOREID
                                  where tra_h.RECEIPTID == receipt &&
                                  tra_h.TYPE == type &&
                                  tra_h.ENTRYSTATUS == entryStatus
                                  select new Transaction()
                {
                    ReceiptID = tra_h.RECEIPTID,
                    StoreID   = sto.STOREID,
                    Name      = sto.NAME,
                    TransDate = tra_h.TRANSDATE ?? DateTime.MinValue,
                    NetAmount = tra_h.NETAMOUNT ?? 0
                };
                //  LINENUM   changed to LINENUM = (decimal)tra_i.LINEID  in line 195 colu 156 by rafeeq
                var transactionLine = from tra_h in db.RBOTRANSACTIONTABLE
                                      join tra_l in db.RBOTRANSACTIONSALESTRANS
                                      on tra_h.TRANSACTIONID equals tra_l.TRANSACTIONID
                                      join tra_i in db.RBOTRANSACTIONINFOCODETRANS
                                      on
                                      new { tra_l.TRANSACTIONID, tra_l.LINENUM, INFOCODEID = Program.isDelevary } equals new { tra_i.TRANSACTIONID, LINENUM = (decimal)tra_i.LINEID, tra_i.INFOCODEID } into info_d
                from info in info_d.DefaultIfEmpty()
                join info_sub in db.RBOINFORMATIONSUBCODETABLE on
                    info.INFORMATION equals info_sub.SUBCODEID into info_sub_d
                from info_s in info_sub_d.DefaultIfEmpty()
                where tra_h.RECEIPTID == receipt &&
                tra_h.TYPE == type &&
                tra_h.ENTRYSTATUS == entryStatus &&
                tra_l.TRANSACTIONSTATUS == transactionStatus
                    select new TransactionLine()
                {
                    ItemId         = tra_l.ITEMID,
                    Description    = tra_l.DESCRIPTION,
                    Qty            = (tra_l.QTY ?? 0) * -1,
                    TaxInckInPrice = tra_l.TAXINCLINPRICE ?? 0,
                    Comment        = tra_l.COMMENT,
                    ExtraInfo      = string.IsNullOrEmpty(info_s.DESCRIPTION) ? "NON DELIVERABLE" : info_s.DESCRIPTION
                };

                var transactionCustomer = from tra_h in db.RBOTRANSACTIONTABLE
                                          join tra_i in db.RBOTRANSACTIONINFOCODETRANS
                                          on
                                          new { tra_h.TRANSACTIONID, INFOCODEID = Program.customerInfoCode } equals new { tra_i.TRANSACTIONID, tra_i.INFOCODEID } into info_d
                from info in info_d.DefaultIfEmpty()
                join cust in db.CUSTTABLE on new { CUSTACCOUNT = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION } equals
                new { CUSTACCOUNT = cust.ACCOUNTNUM }
                join address in db.CUSTOMERADDRESS on
                new { cust.ACCOUNTNUM, ADDRESSTYPE = defaultAddressType } equals new { address.ACCOUNTNUM, address.ADDRESSTYPE }
                where tra_h.RECEIPTID == receipt &&
                tra_h.TYPE == type &&
                tra_h.ENTRYSTATUS == entryStatus
                select new TransactionCustomer()
                {
                    ReceiptID   = tra_h.RECEIPTID,
                    CustAccount = string.IsNullOrEmpty(info.INFORMATION) ? tra_h.CUSTACCOUNT : info.INFORMATION,
                    Name        = cust.NAME,
                    Address     = cust.ADDRESS,
                    Phone       = cust.PHONE,
                    Address1    = address.ADDRESS,
                    Street      = address.STREET
                };

                TransactionHeader = transaction.Count() > 0 ? transaction.ToList()[0] : null;

                TransactionLines = transactionLine.Count() > 0 ? new TransactionLines(transactionLine.ToList()) : null;

                TransactionCustomer = transactionCustomer.Count() > 0 ? transactionCustomer.ToList()[0] : null;

                this.dataGridViewReceipt.DataSource = transaction.ToList();

                this.dataGridViewTransaction.DataSource = transactionLine.ToList();


                this.dataGridViewCustomer.DataSource = transactionCustomer.ToList();

                this.TransactionBindingSource.DataSource = TransactionHeader;

                this.TransactionCustomerBindingSource.DataSource = TransactionCustomer;

                this.TransactionLinesBindingSource.DataSource = TransactionLines;

                //ReportDataSource dataSourceTran = new ReportDataSource("Transaction", transaction.Count() > 0 ? transaction.ToList()[0] : null);
                //ReportDataSource dataSourceCust = new ReportDataSource("TrransactionCustomer", transactionCustomer.Count() > 0 ? transactionCustomer.ToList()[0] : null);
                //ReportDataSource dataSourceLine = new ReportDataSource("TransactionLines", transactionLine.Count() > 0 ? new TransactionLines(transactionLine.ToList()) : null);

                //this.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceTran);
                //Sthis.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceCust);
                //this.reportViewerDelivary.LocalReport.DataSources.Add(dataSourceLine);
                if (transaction.Count() > 0)
                {
                    String PrinterName = SettingsProvider.GetDefaultPrinter();

                    string ReportPath = reportViewerDelivary.LocalReport.ReportEmbeddedResource;

                    using (ReportPriner Printer = new ReportPriner(ReportPath, reportViewerDelivary.LocalReport.DataSources, null))
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            Printer.Run(PrinterName);
                        }
                    }
                }
                sendSMS(receipt, true);
            }
            if (!Program.KeepOpen)
            {
                this.Close();
            }
        }
コード例 #3
0
        private void buttonPrint_Click(object sender, EventArgs e)
        {
            int Selection = this.dataGridViewJournel.CurrentCell.RowIndex;

            Warranties = DataProvider.GetWarrenties(0, 10, null,
                                                    this.dataGridViewJournel.CurrentRow.Cells["WarrentyNumber"].Value.ToString(),
                                                    null, null, null);
            Warranty TempWarrenties = (Warranty)Warranties.Clone();

            var errorMessage = this.dataGridViewJournel.CurrentRow.Cells["ErrorMessage"].Value.ToString();

            if (errorMessage.Length > 0)
            {
                DialogResult result =
                    MessageBox.Show(this, "Warranty Slip Has Errors."
                                    + Environment.NewLine + errorMessage +
                                    Environment.NewLine +
                                    "Still Need the Warranty Slip.", "Cannot Generate",
                                    MessageBoxButtons.YesNoCancel);

                if (result == DialogResult.Yes)
                {
                    result = new Authorize().ShowDialog(this);
                }
                if (result != DialogResult.Yes)
                {
                    return;
                }
            }
            #region PrintExtended
            TempWarrenties.Clear();
            TempWarrenties.Add(Warranties[0]);
            TempWarrenties.Reciept = Warranties[0].Reciept;

            const string ReportPath     = @"LSExtendedWarrenty.WarrentySlip.rdlc";
            const string DataSourceName = @"WarrentyItem";
            String       PrinterName    = SettingsProvider.GetDefaultPrinter();
            try
            {
                Microsoft.Reporting.WinForms.ReportParameter[] ReportParameter =
                    new Microsoft.Reporting.WinForms.ReportParameter[] {
                    new Microsoft.Reporting.WinForms.ReportParameter(@"PrintDateTime", DateTime.Now.ToString()),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"IssueDateTime", TempWarrenties[0].IssuedDate.ToString()),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"CashMemo", TempWarrenties[0].Reciept.RecieptID),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"CashMemoDate", TempWarrenties[0].Reciept.TransactionDate.ToString()),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"CustomerName", TempWarrenties[0].CustomerName),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"CustomerPhone", TempWarrenties[0].Phone),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"CustomerEmail", TempWarrenties[0].Email),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"StaffCode", TempWarrenties[0].Reciept.Staff),
                    new Microsoft.Reporting.WinForms.ReportParameter(@"StaffName", TempWarrenties[0].Reciept.StaffName)
                };


                Microsoft.Reporting.WinForms.ReportDataSource DataSource = new Microsoft.Reporting.WinForms.ReportDataSource
                                                                               (DataSourceName, TempWarrenties);
                using (ReportPriner Printer = new ReportPriner(ReportPath, DataSource, ReportParameter))
                {
                    this.Hide();
                    this.Cursor = Cursors.WaitCursor;
                    FormReciept window = new FormReciept();
                    window.Report          = Printer.LocalReport;
                    window.ReportParameter = ReportParameter;
                    window.DataSource      = DataSource;
                    this.Cursor            = Cursors.Default;
                    window.ShowDialog(this);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error Processing the Warranty Slip. "
                                + Environment.NewLine
                                + "Please Check the Error Message." + Environment.NewLine
                                + "Please take a screen shot and send to System Administrator" + Environment.NewLine + Environment.NewLine
                                + ex.Message, "Error Occurred");
            }
            #endregion
        }
コード例 #4
0
        private void buttonPay_Click(object sender, EventArgs e)
        {
            if (Warranties != null)
            {
                if (this.ValidateForPrint())
                {
                    ConfirmPayment ConfirmPayment = new ConfirmPayment();
                    var            temp           = this.Warranties;
                    DialogResult   Result         = ConfirmPayment.ShowDialog(this, ref temp);
                    this.Warranties = temp;
                    if (Result == DialogResult.OK && ConfirmPayment.IsValid == true)
                    {
                        this.IsBusy = true;
                        this.Warranties.CustomerName = this.textBoxCustomerName.Text;
                        this.Warranties.Email        = this.textBoxEmail.Text;
                        this.Warranties.Phone        = this.textBoxPhoneNumber.Text;
                        this.Warranties.Country      = this.comboBoxCountry.Text;
                        this.Warranties.Address      = this.textBoxAddress.Text;
                        bool succesCommit = false;
                        try
                        {
                            this.Warranties.Commit();
                            succesCommit = true;
                        }
                        catch (Exception ex)
                        {
                            this.Warranties.RollBack();

                            MessageBox.Show("Error Occurred While Committing Warranty. "
                                            + Environment.NewLine
                                            + "Please Check the Error Message." + Environment.NewLine
                                            + "Please take a screen shot and send to System Administrator" + Environment.NewLine + Environment.NewLine
                                            + ex.Message, "Error Occurred.");
                            succesCommit = false;
                        }
                        if (succesCommit)
                        {
                            const string ReportPath     = @"LSExtendedWarrenty.WarrentySlip.rdlc";
                            const string DataSourceName = @"WarrentyItem";
                            String       PrinterName    = SettingsProvider.GetDefaultPrinter();
                            Microsoft.Reporting.WinForms.ReportParameter[] ReportParameter =
                                new Microsoft.Reporting.WinForms.ReportParameter[] {
                                new Microsoft.Reporting.WinForms.ReportParameter(@"PrintDateTime", DateTime.Now.ToString()),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"IssueDateTime", DateTime.Now.ToString()),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"CashMemo", Warranties.Reciept.RecieptID),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"CashMemoDate", Warranties.Reciept.TransactionDate.ToString()),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"CustomerName", Warranties.CustomerName),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"CustomerPhone", Warranties.Phone),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"CustomerEmail", Warranties.Email),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"StaffCode", Warranties.Reciept.Staff),
                                new Microsoft.Reporting.WinForms.ReportParameter(@"StaffName", Warranties.Reciept.StaffName)
                            };
                            Warranty TempWarrenties = (Warranty)Warranties.Clone();
                            try
                            {
                                foreach (var warranty in Warranties)
                                {
                                    TempWarrenties.Clear();
                                    TempWarrenties.Add(warranty);
                                    Microsoft.Reporting.WinForms.ReportDataSource DataSource = new Microsoft.Reporting.WinForms.ReportDataSource
                                                                                                   (DataSourceName, TempWarrenties);
                                    using (ReportPriner Printer = new ReportPriner(ReportPath, DataSource, ReportParameter))
                                    {
                                        Printer.Run(PrinterName);
                                        Printer.Run(PrinterName);
                                    }
                                }
                                this.Warranties = null;
                                this.Reciept    = null;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Problem Printing Warranty Certificate.\nPlease Try again."
                                                + Environment.NewLine
                                                + "Please Check the Error Message." + Environment.NewLine
                                                + "Please take a screen shot and send to System Administrator" + Environment.NewLine + Environment.NewLine
                                                + ex.Message
                                                , "Cannot Print.");
                                this.Warranties.RollBack();
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "Problem saving Warranty.", "Cannot Save.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        if (ConfirmPayment.IsValid)
                        {
                            MessageBox.Show(this, "Invalid Payment", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, "Please Enter All the user Fields.", "Complete the form.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                this.IsBusy = false;
            }
        }