Exemple #1
0
 private void Cleaning()
 {
     NodeBrand.Clear();
     NodeModel.Clear();
     NodePrice.Clear();
     Maintenance.Clear();
     Warranty.Clear();
     Material.Clear();
     Year.Clear();
 }
Exemple #2
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
        }
Exemple #3
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;
            }
        }