コード例 #1
0
        internal static Warranty Warrenties(bool Updated)
        {
            Warranty warrenty = new Warranty();

            if (POSConnection.State != System.Data.ConnectionState.Open)
            {
                POSConnection.Open();
                SqlCommand   command = new SqlCommand(SQL_SELECT_WARRENTY, POSConnection);
                WarrentyItem temp    = new WarrentyItem();

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var warranty_id       = reader.GetValue(0);
                    var warranty_number   = reader.GetValue(1);
                    var show_room         = reader.GetValue(2);
                    var cash_memo         = reader.GetValue(3);
                    var item_code         = reader.GetValue(4);
                    var item_desc         = reader.GetValue(5);
                    var serial_number     = reader.GetValue(6);
                    var retail_price      = reader.GetValue(7);
                    var warranty_years    = reader.GetValue(8);
                    var bill_total        = reader.GetValue(9);
                    var issued_date       = reader.GetValue(10);
                    var customer_name     = reader.GetValue(11);
                    var customer_email    = reader.GetValue(12);
                    var customer_phone    = reader.GetValue(13);
                    var customer_address  = reader.GetValue(14);
                    var payment_cash_memo = reader.GetValue(15);
                    var country           = reader.GetValue(16);
                    temp = new WarrentyItem()
                    {
                        WarrentyNumber = warranty_number.ToString(),
                        ItemId         = item_code.ToString(),
                        Description    = item_desc.ToString(),
                        CustomerName   = customer_name.ToString(),
                        PaymentReciept = DataProvider.GetCashMemo(payment_cash_memo.ToString(), "ALL"),
                        Reciept        = DataProvider.GetCashMemo(cash_memo.ToString(), "ALL")
                    };
                    warrenty.Add(temp);
                }
                reader.Close();
            }
            return(warrenty);
        }
コード例 #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
        }
コード例 #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;
            }
        }
コード例 #4
0
        internal static Warranty Warrenties(int Start,
                                            int End,
                                            string LocationFilter,
                                            String WarrentyFilter,
                                            String RecieptFilter,
                                            String EmailFilter,
                                            String HasErrorsFilter)
        {
            String       SQLQuery = SQL_SELECT_WARRENTY;
            const String WHERE    = " WHERE ";
            const String AND      = " AND ";
            bool         andFlag  = false;

            if (LocationFilter != null ||
                WarrentyFilter != null ||
                RecieptFilter != null ||
                EmailFilter != null ||
                HasErrorsFilter != null)
            {
                SQLQuery = String.Concat(SQLQuery, WHERE);
            }

            if (LocationFilter != null)
            {
                SQLQuery = String.Concat(SQLQuery,
                                         andFlag ?
                                         AND + " show_room = '" + LocationFilter + "'" :
                                         " show_room = '" + LocationFilter + "'");
                andFlag = true;
            }

            if (WarrentyFilter != null)
            {
                SQLQuery = String.Concat(SQLQuery,
                                         andFlag ?
                                         AND + " warranty_number = '" + WarrentyFilter + "'" :
                                         " warranty_number = '" + WarrentyFilter + "'");
                andFlag = true;
            }

            if (RecieptFilter != null)
            {
                SQLQuery = String.Concat(SQLQuery,
                                         andFlag ?
                                         AND + " cash_memo = '" + RecieptFilter + "'" :
                                         " cash_memo = '" + RecieptFilter + "'");
            }

            if (EmailFilter != null)
            {
                SQLQuery = String.Concat(SQLQuery,
                                         andFlag ?
                                         AND + " customer_email = '" + EmailFilter :
                                         " customer_email = '" + EmailFilter);
                andFlag = true;
            }

            if (HasErrorsFilter != null)
            {
                SQLQuery = String.Concat(SQLQuery,
                                         andFlag ?
                                         AND + " LEN([dbo].[EXTENDED_WARRENTY_ERROR](cash_memo,payment_cash_memo))>0 " :
                                         " LEN([dbo].[EXTENDED_WARRENTY_ERROR](cash_memo,payment_cash_memo))>0 ");
                andFlag = true;
            }

            Warranty warrenty = null;

            if (POSConnection.State != System.Data.ConnectionState.Open)
            {
                POSConnection.Open();
                SqlCommand   command = new SqlCommand(SQLQuery, POSConnection);
                WarrentyItem temp    = new WarrentyItem();

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var warranty_id       = reader.GetValue(0);
                    var warranty_number   = reader.GetValue(1);
                    var show_room         = reader.GetValue(2);
                    var cash_memo         = reader.GetValue(3);
                    var item_code         = reader.GetValue(4);
                    var item_desc         = reader.GetValue(5);
                    var serial_number     = reader.GetValue(6);
                    var retail_price      = reader.GetValue(7);
                    var warranty_years    = reader.GetValue(8);
                    var bill_total        = reader.GetValue(9);
                    var issued_date       = reader.GetValue(10);
                    var customer_name     = reader.GetValue(11);
                    var customer_email    = reader.GetValue(12);
                    var customer_phone    = reader.GetValue(13);
                    var customer_address  = reader.GetValue(14);
                    var payment_cash_memo = reader.GetValue(15);
                    var country           = reader.GetValue(16);
                    var error_message     = reader.GetValue(17);
                    if (warrenty == null)
                    {
                        warrenty = new Warranty()
                        {
                        }
                    }
                    ;

                    temp = new WarrentyItem()
                    {
                        WarrentyNumber = warranty_number.ToString(),
                        CustomerName   = customer_name.ToString(),
                        ItemId         = item_code.ToString(),
                        Description    = item_desc.ToString(),
                        IssuedDate     = DateTime.Parse(issued_date.ToString()),
                        SerialNumber   = serial_number.ToString(),
                        Email          = customer_email.ToString(),
                        Phone          = customer_phone.ToString(),
                        Address        = customer_address.ToString(),
                        WarrentyAmount = Int32.Parse(bill_total.ToString()),
                        PaymentReciept = DataProvider.GetCashMemo(payment_cash_memo.ToString(), "ALL"),
                        Reciept        = DataProvider.GetCashMemo(cash_memo.ToString(), "ALL"),
                        RecieptID      = cash_memo.ToString(),
                        NumberOfYears  = Int32.Parse(warranty_years.ToString()),
                        ErrorMessage   = error_message.ToString()
                    };
                    warrenty.Add(temp);
                }
                reader.Close();
            }
            return(warrenty);
        }