Exemplo n.º 1
0
 private void ButtonSearch_Click(object sender, EventArgs e)
 {
     try
     {
         String DateTo   = "";
         String DateFrom = "";
         DateTo   = DateTimePickerTo.Value.Month.ToString() + "/" + DateTimePickerTo.Value.Day.ToString() + "/" + DateTimePickerTo.Value.Year.ToString();
         DateFrom = DateTimePickerFrom.Value.Month.ToString() + "/" + DateTimePickerFrom.Value.Day.ToString() + "/" + DateTimePickerFrom.Value.Year.ToString();
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         if (TextBoxVehicleNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 DatabaseConnectObj.SqlQuery("SELECT VehicleNo, Date FROM Schedule WHERE (VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else
         {
             try
             {
                 DataTable dt = new DataTable();
                 DatabaseConnectObj.SqlQuery("SELECT VehicleNo, Date FROM Schedule WHERE (Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
 private void ButtonReset_Click(object sender, EventArgs e)
 {
     TextBoxVoucherNo.Text = "";
     TextBoxPaidTo.Text    = "";
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         try
         {
             DataTable dt = new DataTable();
             DatabaseConnectObj.SqlQuery("SELECT  Name, Id, DateIssued, value FROM Expences");
             dt = DatabaseConnectObj.ExecuteQuery();
             dataGridView1.DataSource = dt;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             DatabaseConnectObj.DatabaseConnectionClose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void ButtonReset_Click(object sender, EventArgs e)
 {
     ComboBoxServiceName.Text = "";
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         try
         {
             DataTable dt = new DataTable();
             DatabaseConnectObj.SqlQuery("SELECT ItemName, ItemDesc, ItemPrice FROM Items");
             dt = DatabaseConnectObj.ExecuteQuery();
             dataGridView1.DataSource = dt;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             DatabaseConnectObj.DatabaseConnectionClose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void ReportingService_Load(object sender, EventArgs e)
 {
     ComboBoxServiceName.Items.Clear();
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         try
         {
             DataTable dt = new DataTable();
             DatabaseConnectObj.SqlQuery("SELECT ItemName, ItemDesc, ItemPrice FROM Items");
             dt = DatabaseConnectObj.ExecuteQuery();
             foreach (DataRow row in dt.Rows)
             {
                 ComboBoxServiceName.Items.Add(row["ItemName"].ToString());
             }
             dataGridView1.DataSource = dt;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             DatabaseConnectObj.DatabaseConnectionClose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void SelectCustomer_Load(object sender, EventArgs e)
 {
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         try
         {
             DataTable dt = new DataTable();
             DatabaseConnectObj.SqlQuery("SELECT CustomerName, CustomerNo, VehicleNo FROM Customer");
             dt = DatabaseConnectObj.ExecuteQuery();
             foreach (DataRow row in dt.Rows)
             {
                 CheckBoxListCusList.Items.Add(row["CustomerName"].ToString().Trim() + "     (" + row["VehicleNo"].ToString() + ")");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             DatabaseConnectObj.DatabaseConnectionClose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private DataTable getCustomerVehicleData()
        {
            DataTable result = new DataTable();

            try
            {
                ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
                try
                {
                    DatabaseConnectObj.SqlQuery("SELECT Id,VehicleName,VehicleType FROM Vehicle");
                    result = DatabaseConnectObj.ExecuteQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DatabaseConnectObj.DatabaseConnectionClose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(result);
        }
Exemplo n.º 7
0
        private void ReportingInvoice_Load(object sender, EventArgs e)
        {
            try
            {
                ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
                try //load datagrid
                {
                    DataTable dt = new DataTable();
                    DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId");
                    dt = DatabaseConnectObj.ExecuteQuery();
                    dataGridView1.DataSource = dt;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DatabaseConnectObj.DatabaseConnectionClose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            Decimal temp = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows) //calculate total
            {
                temp += Convert.ToDecimal(row.Cells["total"].Value);
            }
            TextBoxTotal.Text = temp.ToString(); //update total
        }
Exemplo n.º 8
0
 private void ButtonReset_Click(object sender, EventArgs e)
 {
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         try
         {
             DataTable dt = new DataTable();
             DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId");
             dt = DatabaseConnectObj.ExecuteQuery();
             dataGridView1.DataSource = dt;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             DatabaseConnectObj.DatabaseConnectionClose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     TextBoxCusName.Text    = "";
     TextBoxCusContact.Text = "";
     TextBoxVehicleNo.Text  = "";
     TextBoxInvoiceNo.Text  = "";
 }
        private DataTable getCustomerItemData()
        {
            DataTable result = new DataTable();

            try
            {
                ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
                try
                {
                    DatabaseConnectObj.SqlQuery("SELECT ItemId, ItemName, ItemDesc, ItemPrice, VehicleId FROM Items");
                    result = DatabaseConnectObj.ExecuteQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DatabaseConnectObj.DatabaseConnectionClose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(result);
        }
Exemplo n.º 10
0
 private void NewVoucher_Load(object sender, EventArgs e)
 {
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         try
         {
             DataTable dt = new DataTable();
             DatabaseConnectObj.SqlQuery("SELECT MAX(Id) AS voucherno FROM Expences");
             dt = DatabaseConnectObj.ExecuteQuery();
             foreach (DataRow row in dt.Rows)
             {
                 TextBoxVoucherNo.Text = (Convert.ToInt32(row["voucherno"].ToString()) + 1).ToString();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             TextBoxVoucherNo.Text = "1";
         }
         finally
         {
             DatabaseConnectObj.DatabaseConnectionClose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 11
0
 private void SchedulerSmsReport_Load(object sender, EventArgs e)
 {
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         try
         {
             DataTable dt = new DataTable();
             DatabaseConnectObj.SqlQuery("SELECT VehicleNo, Date FROM Schedule");
             dt = DatabaseConnectObj.ExecuteQuery();
             dataGridView1.DataSource = dt;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             DatabaseConnectObj.DatabaseConnectionClose();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void ButtonSearch_Click(object sender, EventArgs e)
 {
     try
     {
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         if (ComboBoxServiceName.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 DatabaseConnectObj.SqlQuery("SELECT ItemName, ItemDesc, ItemPrice FROM Items WHERE (ItemName = '" + ComboBoxServiceName.Text + "')");
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else
         {
             MessageBox.Show("Enter a product name");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 13
0
        private void MountlyReport_Load(object sender, EventArgs e)
        {
            try
            {
                ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
                try
                {
                    DataTable dt = new DataTable();
                    DatabaseConnectObj.SqlQuery("SELECT  Name, Id, DateIssued, value FROM Expences");
                    dt = DatabaseConnectObj.ExecuteQuery();
                    dataGridView1.DataSource = dt;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DatabaseConnectObj.DatabaseConnectionClose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Decimal temp = 0;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                temp += Convert.ToDecimal(row.Cells["total"].Value);
            }
            TextBoxTotal.Text = temp.ToString();
        }
        private void ButtonSave_Click_1(object sender, EventArgs e)
        {
            Int64  n;
            string temp = TextBoxCusNo.Text.Trim();
            bool   flag = Int64.TryParse(temp, out n);

            if (TextBoxVehicleNo.Text.Trim() == "")
            {
                MessageBox.Show("please enter a vehicle number");
                TextBoxVehicleNo.Focus();
            }
            else if (flag) //check if the input is number or characters
            {
                try
                {
                    ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
                    try
                    {
                        if (ComboBoxVehicleName.Text.Trim() == "")
                        {
                            DatabaseConnectObj.SqlQuery("SELECT Id FROM Vehicle WHERE (VehicleType = '" + ComboBoxVehicleModel.Text.Trim() + "') AND (VehicleName is NULL)");
                        }
                        else
                        {
                            DatabaseConnectObj.SqlQuery("SELECT Id FROM Vehicle WHERE (VehicleType = '" + ComboBoxVehicleModel.Text.Trim() + "') AND (VehicleName = '" + ComboBoxVehicleName.Text.Trim() + "')");
                        }
                        DataTable result = DatabaseConnectObj.ExecuteQuery();
                        DatabaseConnectObj.SqlQuery("INSERT INTO Customer (CustomerName, CustomerNo, VehicleNo, VehicleId) VALUES ('" + TextBoxCusName.Text.Trim() + "','" + TextBoxCusNo.Text.Trim() + "','" + TextBoxVehicleNo.Text.Trim() + "','" + result.Rows[0]["Id"].ToString().Trim() + "')");
                        DatabaseConnectObj.ExecutNonQuery();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        TextBoxCusName.Text       = "";
                        TextBoxCusNo.Text         = "";
                        TextBoxVehicleNo.Text     = "";
                        ComboBoxVehicleModel.Text = "";
                        ComboBoxVehicleName.Text  = "";
                    }
                }
                catch (Exception es)
                {
                    MessageBox.Show(es.Message);
                }
            }
            else
            {
                MessageBox.Show("enter a valid customer contact number");
                TextBoxVehicleNo.Focus();
            }
        }
Exemplo n.º 15
0
        private void getLaboursData()
        {
            ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();

            try
            {
                DatabaseConnectObj.SqlQuery("SELECT LabourId, LabourName, LabourDesc, LabourPrice FROM Labour");
                laboursdata = DatabaseConnectObj.ExecuteQuery();
            }
            catch (Exception ex)
            {
                string output = ex.Message + " getLaboursData"; MessageBox.Show(output);
            }
            finally
            {
                DatabaseConnectObj.DatabaseConnectionClose();
            }
        }
Exemplo n.º 16
0
        private void getItemsData()
        {
            ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();

            try
            {
                DatabaseConnectObj.SqlQuery("SELECT ItemId, ItemName, ItemDesc, ItemPrice, VehicleId FROM dbo.Items");
                itemsData = DatabaseConnectObj.ExecuteQuery();
            }
            catch (Exception ex)
            {
                string output = ex.Message + " getItemsData"; MessageBox.Show(output);
            }
            finally
            {
                DatabaseConnectObj.DatabaseConnectionClose();
            }
        }
Exemplo n.º 17
0
        private void getCustomerData()
        {
            ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();

            try
            {
                DatabaseConnectObj.SqlQuery("SELECT CustomerId, CustomerName, CustomerNo, VehicleNo, VehicleId FROM dbo.Customer");
                customerData = DatabaseConnectObj.ExecuteQuery();
            }
            catch (Exception ex)
            {
                string output = ex.Message + " getCustomerData"; MessageBox.Show(output);
            }
            finally
            {
                DatabaseConnectObj.DatabaseConnectionClose();
            }
        }
Exemplo n.º 18
0
        private void getVehicleData()
        {
            ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();

            try
            {
                DatabaseConnectObj.SqlQuery("SELECT Id, VehicleType, VehicleName FROM dbo.Vehicle");
                vehicledata = DatabaseConnectObj.ExecuteQuery();
            }
            catch (Exception ex)
            {
                string output = ex.Message + " getVehicleData"; MessageBox.Show(output);
            }
            finally
            {
                DatabaseConnectObj.DatabaseConnectionClose();
            }
        }
        private void loadCustomerAndVehicleData()
        {
            ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();

            try
            {
                DataTable dt = new DataTable();
                DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.CustomerNo, Customer.VehicleNo, Vehicle.VehicleType, Vehicle.VehicleName FROM Customer INNER JOIN Vehicle ON Customer.VehicleId = Vehicle.Id");
                dt = DatabaseConnectObj.ExecuteQuery();
                dataCustomerAndVehicle = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DatabaseConnectObj.DatabaseConnectionClose();
            }
        }
        private void ButtonSelect_Click(object sender, EventArgs e)
        {
            String temp = "";

            for (int i = 0; i < CheckBoxListCusList.Items.Count; i++)
            {
                if (CheckBoxListCusList.GetItemChecked(i))
                {
                    String[] sub   = CheckBoxListCusList.Items[i].ToString().Split('(');
                    String[] temp2 = sub[1].Split(')');
                    try
                    {
                        ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
                        try
                        {
                            DataTable dt = new DataTable();
                            DatabaseConnectObj.SqlQuery("SELECT CustomerNo FROM Customer where VehicleNo = '" + temp2[0].Trim() + "'");
                            dt = DatabaseConnectObj.ExecuteQuery();
                            DataRow row = dt.Rows[0];
                            temp = temp + " " + row["CustomerNo"].ToString() + ",";
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        finally
                        {
                            DatabaseConnectObj.DatabaseConnectionClose();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            this.Close();
        }
Exemplo n.º 21
0
        private void Edit_Load(object sender, EventArgs e)
        {
            //get data and load
            getCustomerData();
            //LoadCusCombobox();
            getVehicleData();
            //loadVehiclefield();
            getItemsData();
            getLaboursData();

            //get invoice detail from reposrt window
            String[] substrings = nm.Split(',');            //get value as a object instead of using pass value
            typeEdit       = substrings[1];
            groupBox1.Text = "Edit " + typeEdit;
            if (typeEdit == "Estimate")
            {
                ButtonMakeInvoice.Visible = true;
            }
            NumericInvoiceNo.Value = Convert.ToDecimal(substrings[0].ToString().Trim());
            string  vehicleIdOfThisInvoice  = customerData.Select("VehicleNo = '" + substrings[4].ToString().Trim() + "'")[0]["VehicleId"].ToString().Trim();
            DataRow vehicleRowOfThisInvoice = vehicledata.Select("Id = '" + vehicleIdOfThisInvoice + "'")[0];

            ComboBoxVehicleModel.Text  = vehicleRowOfThisInvoice["VehicleType"].ToString().Trim();
            ComboBoxVehicleName.Text   = vehicleRowOfThisInvoice["VehicleName"].ToString().Trim();
            LableInvoiceId.Text        = substrings[5];
            ComboBoxClientName.Text    = substrings[2] + " ( " + substrings[4] + " )";
            DateTimePickerIssued.Value = Convert.ToDateTime(substrings[3]);
            try
            {
                ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();

                //get invoice items details
                try
                {
                    DataTable dt = new DataTable();
                    DatabaseConnectObj.SqlQuery("SELECT Items.ItemName, BillItemDetails" + typeEdit + ".Quantity, BillItemDetails" + typeEdit + ".price, BillItemDetails" + typeEdit + ".Tax, BillItemDetails" + typeEdit + ".ItemNo FROM BillItemDetails" + typeEdit + " INNER JOIN Items ON BillItemDetails" + typeEdit + ".ItemNo = Items.ItemId WHERE (BillItemDetails" + typeEdit + "." + typeEdit + "id = '" + LableInvoiceId.Text + "')");
                    dt = DatabaseConnectObj.ExecuteQuery();
                    dataGridItems.DataSource = dt;
                }
                catch (Exception ex)
                {
                    string output = ex.Message + " load items details"; MessageBox.Show(output);
                }

                //get invoice labour details
                try
                {
                    DataTable dt = new DataTable();
                    DatabaseConnectObj.SqlQuery("SELECT Labour.LabourName, BillLabourDetail" + typeEdit + ".price, BillLabourDetail" + typeEdit + ".Tax, BillLabourDetail" + typeEdit + ".LabourNo FROM BillLabourDetail" + typeEdit + " INNER JOIN Labour ON BillLabourDetail" + typeEdit + ".LabourNo = Labour.LabourId WHERE (BillLabourDetail" + typeEdit + "." + typeEdit + "id = '" + LableInvoiceId.Text + "')");
                    dt = DatabaseConnectObj.ExecuteQuery();
                    DataGridLabour.DataSource = dt;
                }
                catch (Exception ex)
                {
                    string output = ex.Message + " load labour details"; MessageBox.Show(output);
                }
                if (typeEdit == "Invoice")
                {
                    try
                    {
                        DataTable dt = new DataTable();
                        DatabaseConnectObj.SqlQuery("SELECT due FROM " + typeEdit + " WHERE (" + typeEdit + "id = '" + LableInvoiceId.Text + "')");
                        dt = DatabaseConnectObj.ExecuteQuery();
                        foreach (DataRow row in dt.Rows)
                        {
                            due = row["due"].ToString().Trim();
                        }
                    }
                    catch (Exception ex)
                    {
                        string output = ex.Message + " load due details"; MessageBox.Show(output);
                    }
                }
                //get remark
                try
                {
                    DataTable dt = new DataTable();
                    DatabaseConnectObj.SqlQuery("SELECT remark FROM " + typeEdit + " WHERE (" + typeEdit + "id = '" + LableInvoiceId.Text + "')");
                    dt = DatabaseConnectObj.ExecuteQuery();
                    foreach (DataRow row in dt.Rows)
                    {
                        TextBoxRemark.Text = row["remark"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DatabaseConnectObj.DatabaseConnectionClose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //load the total and sub total
            loadTotalAndSubTotal();
            if (typeEdit == "Invoice")
            {
                TextBoxPaid.Text = (Convert.ToDecimal(TextBoxTotal.Text.Trim()) - Convert.ToDecimal(due.Trim())).ToString();
            }
        }
Exemplo n.º 22
0
 private void ButtonSearch_Click(object sender, EventArgs e)
 {
     try
     {
         String DateTo   = "";
         String DateFrom = "";
         DateTo   = DateTimePickerTo.Value.Month.ToString() + "/" + DateTimePickerTo.Value.Day.ToString() + "/" + DateTimePickerTo.Value.Year.ToString();
         DateFrom = DateTimePickerFrom.Value.Month.ToString() + "/" + DateTimePickerFrom.Value.Day.ToString() + "/" + DateTimePickerFrom.Value.Year.ToString();
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         if (TextBoxCusName.Text != "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND  (Invoice.due > 0) AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.due > 0) AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.due > 0) AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND  (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.due > 0) AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.due > 0) AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.due > 0) AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.due > 0) AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text != "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.due > 0) AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text != "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%')  AND (Invoice.due > 0) AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%')  AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text != "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.due > 0) AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.due > 0) AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text != "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.due > 0) AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text != "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.due > 0) AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text != "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.due > 0) AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text != "" && TextBoxCusContact.Text != "" && TextBoxVehicleNo.Text != "" && TextBoxInvoiceNo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND (Invoice.due > 0) AND (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE (Customer.CustomerName LIKE '%" + TextBoxCusName.Text + "%') AND  (Customer.CustomerNo = '" + TextBoxCusContact.Text + "') AND (Invoice.InvoiceNo = '" + TextBoxInvoiceNo.Text + "') AND (Customer.VehicleNo = '" + TextBoxVehicleNo.Text + "') AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxCusName.Text == "" && TextBoxCusContact.Text == "" && TextBoxVehicleNo.Text == "" && TextBoxInvoiceNo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 if (CheckBoxDue.Checked == true)
                 {
                     DatabaseConnectObj.SqlQuery("SELECT Customer.CustomerName, Customer.VehicleNo, Invoice.InvoiceNo, Invoice.Date, Invoice.total, Invoice.due, Invoice.invoiceid FROM Invoice INNER JOIN Customer ON Invoice.CustomerId = Customer.CustomerId WHERE  (Invoice.due > 0) AND (Invoice.Date BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 }
                 else
                 {
                 }
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 23
0
 private void ButtonSearch_Click(object sender, EventArgs e)
 {
     try
     {
         String DateTo   = "";
         String DateFrom = "";
         DateTo   = DateTimePickerTo.Value.Month.ToString() + "/" + DateTimePickerTo.Value.Day.ToString() + "/" + DateTimePickerTo.Value.Year.ToString();
         DateFrom = DateTimePickerFrom.Value.Month.ToString() + "/" + DateTimePickerFrom.Value.Day.ToString() + "/" + DateTimePickerFrom.Value.Year.ToString();
         ClassDatabaseConnection DatabaseConnectObj = new ClassDatabaseConnection();
         if (TextBoxVoucherNo.Text != "" && TextBoxPaidTo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 DatabaseConnectObj.SqlQuery("SELECT Name, Id, DateIssued, value FROM Expences WHERE (Id = '" + TextBoxVoucherNo.Text + "') AND (DateIssued BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxVoucherNo.Text == "" && TextBoxPaidTo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 DatabaseConnectObj.SqlQuery("SELECT Name, Id, DateIssued, value FROM Expences WHERE (Name LIKE '%" + TextBoxPaidTo.Text + "%') AND (DateIssued BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxVoucherNo.Text != "" && TextBoxPaidTo.Text != "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 DatabaseConnectObj.SqlQuery("SELECT Name, Id, DateIssued, value FROM Expences WHERE (Id = '" + TextBoxVoucherNo.Text + "') AND (Name LIKE '%" + TextBoxPaidTo.Text + "%') AND (DateIssued BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
         else if (TextBoxVoucherNo.Text == "" && TextBoxPaidTo.Text == "")
         {
             try
             {
                 DataTable dt = new DataTable();
                 DatabaseConnectObj.SqlQuery("SELECT Name, Id, DateIssued, value FROM Expences WHERE (DateIssued BETWEEN '" + DateFrom + "' AND '" + DateTo + "')");
                 dt = DatabaseConnectObj.ExecuteQuery();
                 dataGridView1.DataSource = dt;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 DatabaseConnectObj.DatabaseConnectionClose();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }