Esempio n. 1
0
 private void ModifyCentral_Validated(object sender, EventArgs e)
 {
     if (ModifyCentral.Text != string.Empty)
     {
         if (pr.GetNumber(ModifyCentral.Text) > 0)
         {
             MessageBox.Show("هذاالسنترال موجود");
             CellactCentral.Clear();
             ModifyCentral.Clear();
         }
     }
 }
Esempio n. 2
0
 private void Delete_Click(object sender, EventArgs e)
 {
     try
     {
         num = pr.GetNumber(CellactCentral.Text);
         var k         = dataGridView1.CurrentRow.Index;
         var DBonWork  = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         var deletcent = (from c in DBonWork.Centrals
                          where c.IDcentral.Equals(num)
                          select c).FirstOrDefault();
         DBonWork.Centrals.DeleteOnSubmit(deletcent);
         DBonWork.SubmitChanges();
         Program.InfoCentralList.RemoveAt(k);
         comboBox1.Items.Clear();
         foreach (var item in Program.InfoCentralList)
         {
             comboBox1.Items.Add(item.CentralName);
         }
         this.dataGridView1.DataSource = null;
         this.dataGridView1.DataSource = Program.InfoCentralList;
     }
     catch (SqlException ex)
     {
         if (ex.Number == 547)
         {
             MessageBox.Show("السنترال يحتوى على بيانات يجب حذفهااولا");
         }
         else
         {
             MessageBox.Show(ex.ToString());
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.ToString());
     }
     finally
     {
         CellactCentral.Clear();
         ModifyCentral.Clear();
     }
 }
Esempio n. 3
0
 private void Modify_Click(object sender, EventArgs e)
 {
     if (ModifyCentral.Text != string.Empty)
     {
         try
         {
             num = pr.GetNumber(CellactCentral.Text);
             var k          = dataGridView1.CurrentRow.Index;
             var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             var updatacent = (from c in DBonWork.Centrals
                               where c.IDcentral.Equals(num)
                               select c).FirstOrDefault();
             updatacent.CentralName = ModifyCentral.Text;
             DBonWork.SubmitChanges();
             Program.InfoCentralList.RemoveAt(k);
             Program.InfoCentralList.Add(updatacent);
             this.dataGridView1.DataSource = null;
             this.dataGridView1.DataSource = Program.InfoCentralList;
             comboBox1.Items.Clear();
             foreach (var item in Program.InfoCentralList)
             {
                 comboBox1.Items.Add(item.CentralName);
             }
             CellactCentral.Clear();
             ModifyCentral.Clear();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
     else
     {
         MessageBox.Show("ادخل اسم السنترال");
     }
 }
Esempio n. 4
0
 private void dataGridView1_Click(object sender, EventArgs e)
 {
     CellactCentral.Clear();
     ModifyCentral.Clear();
 }