Exemplo n.º 1
0
 partial void Deletecustomer(customer instance);
Exemplo n.º 2
0
 partial void Insertcustomer(customer instance);
Exemplo n.º 3
0
 partial void Updatecustomer(customer instance);
Exemplo n.º 4
0
        private void button5_Click(object sender, EventArgs e)
        {
            NIC = textBox5.Text;

            label20.Text = Gender;
            label22.Text = Age.ToString();

            if (button5.Text == "Edit" && comboBox3.Text != "")
            {
                Name    = textBox4.Text;
                Address = textBox6.Text;
                CID     = comboBox3.Text;
                NIC     = textBox5.Text;

                Income = comboBox4.Text;

                try
                {
                    DataClasses1DataContext dr = new DataClasses1DataContext();
                    customer c = dr.customers.Single(id => id.CustomerID == CID);
                    c.CustomerID   = CID;
                    c.CustomerName = Name;
                    c.NIC          = NIC;
                    c.Address      = Address;
                    c.Gender       = Gender;
                    c.Age          = Age;
                    c.Income       = Income;
                    dr.SubmitChanges();
                    MessageBox.Show("Data edited Succcessfully");

                    // TODO: This line of code loads data into the 'bank_SystemDataSet2.customer' table. You can move, or remove it, as needed.
                    this.customerTableAdapter1.Fill(this.bank_SystemDataSet2.customer);


                    comboBox3.Text = "";
                    textBox4.Text  = "";
                    textBox5.Text  = "";
                    label20.Text   = "";
                    label22.Text   = "";
                    textBox6.Text  = "";
                    comboBox4.Text = "";

                    comboBox3.Enabled = false;
                    textBox4.Enabled  = false;
                    textBox5.Enabled  = false;
                    label20.Enabled   = false;
                    label22.Enabled   = false;
                    textBox6.Enabled  = false;
                    comboBox4.Enabled = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else if (button5.Text == "Delete" && comboBox2.Text != "")
            {
                CID = comboBox3.Text;

                DialogResult result = MessageBox.Show("Are You sure want to delete it ?", "Conformation", MessageBoxButtons.YesNoCancel);

                if (result == DialogResult.Yes)
                {
                    try
                    {
                        DataClasses1DataContext dr = new DataClasses1DataContext();
                        customer c = dr.customers.Single(id => id.CustomerID == CID);
                        dr.customers.DeleteOnSubmit(c);
                        dr.SubmitChanges();
                        MessageBox.Show("Data deleted Succcessfully");



                        construtors();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("First Delete the Account");
                    }
                    construtors();

                    comboBox3.Text = "";
                    textBox4.Text  = "";
                    textBox5.Text  = "";
                    label20.Text   = "";
                    label22.Text   = "";
                    textBox6.Text  = "";
                    comboBox4.Text = "";

                    comboBox3.Enabled = false;
                    textBox4.Enabled  = false;
                    textBox5.Enabled  = false;
                    label20.Enabled   = false;
                    label22.Enabled   = false;
                    textBox6.Enabled  = false;
                    comboBox4.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show("Check all inputs");
            }
        }