private void button_UpdateCustomer_Click(object sender, EventArgs e)
        {
            ClsBLL   clsBllObj   = new ClsBLL();
            Customer customerObj = new Customer();

            customerObj.CustomerID1   = textBox_CustomerID.Text.Trim();
            customerObj.CompanyName1  = textBox_CompanyName.Text.Trim();
            customerObj.ContactName1  = textBox_ContactName.Text.Trim();
            customerObj.ContactTitle1 = textBox_ContactTitle.Text.Trim();
            customerObj.Address1      = textBox_Address.Text.Trim();
            customerObj.City1         = textBox_City.Text.Trim();
            customerObj.Country1      = textBox_Country.Text.Trim();
            customerObj.Fax1          = textBox_Fax.Text.Trim();
            customerObj.Phone1        = textBox_Phone.Text.Trim();
            customerObj.PostalCode1   = textBox_PostalCode.Text.Trim();
            customerObj.Region1       = textBox_Region.Text.Trim();
            try
            {
                int rowsAffected = clsBllObj.UpdateCustomer(customerObj);
                if (rowsAffected == 1)
                {
                    MessageBox.Show("Customer details updated successfully");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void button_ViewAllCustomers_Click(object sender, EventArgs e)
        {
            ClsBLL ClsBllObj = new ClsBLL();

            dataGrid_CustomerDetails.DataSource = ClsBllObj.ViewAllCustomers();
            this.button_Search.Enabled          = true;
            //label_CustomerID.Visible = true;
            //textBox_CustomerID.Visible = true;
            //button_Search.Visible = true;
            //dataGrid_CustomerDetails.Visible = true;
        }
Exemplo n.º 3
0
        private void button_Login_Click(object sender, EventArgs e)
        {
            Homepage HomeFormObj = new Homepage();
            ClsBLL   clSBLLObj   = new ClsBLL();

            if (clSBLLObj.Login(textBox_Username.Text, textBox_Password.Text))
            {
                MessageBox.Show("Login Successful");
                HomeFormObj.ShowDialog();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Login Unsuccessful. Either the username or the password is incorrect");
            }
        }
Exemplo n.º 4
0
        private void button_DeleteCustomer_Click(object sender, EventArgs e)
        {
            //Get CustomerID value from the selected row of DataGridView
            string customerID       = dataGrid_CustomerDetails.SelectedRows[0].Cells[0].Value.ToString().Trim();
            var    resultMessageBox = MessageBox.Show("Are you sure you want to permanently delete the selected Customer?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resultMessageBox == DialogResult.Yes)
            {
                // user clicked yes
                ClsBLL ClsBllObj = new ClsBLL();
                ClsBllObj.DeleteCustomer(customerID);
                MessageBox.Show("Customer \"" + customerID + "\" has been deleted successfully.");
                dataGrid_CustomerDetails.DataSource = ClsBllObj.ViewAllCustomers();
            }
            else
            {
                // user clicked no
            }
        }
Exemplo n.º 5
0
        private void button_Search_Click(object sender, EventArgs e)
        {
            string    customerID = textBox_CustomerID.Text;
            ClsBLL    bLLObj     = new ClsBLL();
            DataTable dT         = new DataTable();

            if (customerID != string.Empty)
            {
                Customer customerObj = bLLObj.SearchCustomer(customerID);
                if (customerObj.CustomerID1 == null)
                {
                    MessageBox.Show("Could not find a customer with the CustomerID:\"" + customerID + "\".");
                }
                else
                {
                    dT.Columns.Add("CustomerID", typeof(string));
                    dT.Columns.Add("CompanyName", typeof(string));
                    dT.Columns.Add("ContactName", typeof(string));
                    dT.Columns.Add("ContactTitle", typeof(string));
                    dT.Columns.Add("Address", typeof(string));
                    dT.Columns.Add("City", typeof(string));
                    dT.Columns.Add("Region", typeof(string));
                    dT.Columns.Add("PostalCode", typeof(string));
                    dT.Columns.Add("Country", typeof(string));
                    dT.Columns.Add("Phone", typeof(string));
                    dT.Columns.Add("Fax", typeof(string));
                    dT.Rows.Add(customerObj.CustomerID1, customerObj.CompanyName1, customerObj.ContactName1, customerObj.ContactTitle1, customerObj.Address1, customerObj.City1, customerObj.Region1, customerObj.PostalCode1, customerObj.Country1, customerObj.Phone1, customerObj.Fax1);
                    dataGrid_CustomerDetails.DataSource = dT;
                    dataGrid_CustomerDetails.Visible    = true;
                }
            }
            else
            {
                MessageBox.Show("Please enter a Customer ID");
            }
        }