예제 #1
0
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "")
     {
         MessageBox.Show("You Cant do anything if the boxes are empty  ", "Warning  ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (label8.Text == "Manage Customer")
         {
             c.UpdateCustomer(Convert.ToInt32(textBox1.Text), textBox2.Text, textBox4.Text, textBox3.Text, Convert.ToInt32("2"));
             MessageBox.Show("Update Seccess", "Update Product ", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.dataGridView1.DataSource = c.Get_All_Customer();
         }
         else
         {
             c.UpdateCustomer(Convert.ToInt32(textBox1.Text), textBox2.Text, textBox4.Text, textBox3.Text, Convert.ToInt32("1"));
             MessageBox.Show("Update Seccess", "Update Product ", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.dataGridView1.DataSource = c.Get_All_Company();
         }
     }
 }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (compbtn.Content == "Add")
            {
                if (txtid.Text == "" || txtname.Text == "" || txtphone.Text == "" || txtaddress.Text == "")
                {
                    MessageBox.Show("You Cant do anything if the boxes are empty  ", "Warning  ", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    c.AddCustomer(Convert.ToInt32(txtid.Text), txtname.Text, txtphone.Text, txtaddress.Text, Convert.ToInt32("1"));
                    MessageBox.Show("Add Seccess", "Add Product ", MessageBoxButton.OK, MessageBoxImage.Information);

                    txtid.Text = c.maxcomp().Rows[0][0].ToString();

                    txtname.Clear();
                    txtphone.Clear();
                    txtaddress.Clear();
                }
            }
            if (compbtn.Content == "Delete")
            {
                if (txtid.Text == "" || txtname.Text == "" || txtphone.Text == "" || txtaddress.Text == "")
                {
                    MessageBox.Show("You Cant do anything if the boxes are empty  ", "Warning  ", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    if (MessageBox.Show("Do you realy want to delete this Product ?", "Delete Product", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
                    {
                        c.Delete_Customer(Convert.ToInt32(txtid.Text));
                        MessageBox.Show("Delete successful", "Delete Product", MessageBoxButton.OK, MessageBoxImage.Information);
                    }


                    else
                    {
                        MessageBox.Show("Delete Cancled", "Delete Product", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                }
            }
            if (compbtn.Content == "Update")
            {
                if (txtid.Text == "" || txtname.Text == "" || txtphone.Text == "" || txtaddress.Text == "")
                {
                    MessageBox.Show("You Cant do anything if the boxes are empty  ", "Warning  ", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    c.UpdateCustomer(Convert.ToInt32(txtid.Text), txtname.Text, txtphone.Text, txtaddress.Text, Convert.ToInt32("1"));
                    MessageBox.Show("Update Seccess", "Update Product ", MessageBoxButton.OK, MessageBoxImage.Information);


                    txtid.Text = c.maxcomp().Rows[0][0].ToString();

                    txtname.Clear();
                    txtphone.Clear();
                    txtaddress.Clear();
                }
            }
        }