示例#1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            //Getting All the value from form
            dc.id         = int.Parse(txtDeaCustID.Text);
            dc.type       = cmbType.Text;
            dc.name       = txtName.Text;
            dc.email      = txtEmail.Text;
            dc.contact    = txtContact.Text;
            dc.address    = txtAddress.Text;
            dc.added_date = DateTime.Now;

            //Getting the Identity of user logged in.
            string  loggeduser = frmLogin.loggedIn;
            userBLL usr        = udal.GetIDFromUsername(loggeduser);

            dc.added_by = usr.id;

            //Creating a boolean variable to check if dealer or customer is Updated or not;
            bool success = dcdal.update(dc);

            //If the value the dealer or customer is update successfully the value of success will be true else it will be false;
            if (success == true)
            {
                //Dealer or customer updated successfully
                MessageBox.Show("Dealer or Customer Updated successfully");
                Clear();
                //Refreshing the Data Grid view
                DataTable dt = dcdal.select();
                dgvDeaCust.DataSource = dt;
            }
            else
            {
                //Fail to Update dealer or customer
                MessageBox.Show("Update failed try again");
            }
        }