Exemplo n.º 1
0
 private void delet_Click(object sender, EventArgs e)
 {
     if (users.Text != string.Empty)
     {
         try
         {
             var I         = dataGridView1.CurrentRow.Index;
             var DBonWork  = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             var userdelet = (from c in DBonWork.Users
                              where c.ID.Equals(users.Text)
                              select c).FirstOrDefault();
             DBonWork.Users.DeleteOnSubmit(userdelet);
             DBonWork.SubmitChanges();
             dt.RemoveAt(I);
             dataGridView1.DataSource = null;
             dataGridView1.DataSource = dt;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Erorr");
         }
         users.Clear();
         users_name.Clear();
         passward.Clear();
         combodegre.Text = null;
     }
 }
Exemplo n.º 2
0
 private void ComboCentral_SelectedIndexChanged(object sender, EventArgs e)
 {
     Numcent = pr.GetNumber(ComboCentral.Text);
     if (ComboCentral.Text != CentralName)
     {
         ComboCabina.Items.Clear();
         CentralName = ComboCentral.Text;
         Main.CabinaInfo.Clear();
         var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         var SelecCabel = (from D in DBonWork.Cabels
                           where D.IDcentral == Numcent
                           from c in DBonWork.Cabels
                           where c.IDcentral == D.IDcentral
                           from P in DBonWork.Cabinas
                           where P.IDCable == c.IDCable
                           select new { P.IDcabina, P.CABINA });
         if (SelecCabel.Count() > 0)
         {
             foreach (var X in SelecCabel.Distinct())
             {
                 ComboCabina.Items.Add(X.CABINA);
                 Main.CabinaInfo.Add(X.IDcabina, X.CABINA);
             }
         }
     }
 }
Exemplo n.º 3
0
 private void add_Click(object sender, EventArgs e)
 {
     if (users.Text == string.Empty || users_name.Text == string.Empty || passward.Text == string.Empty || combodegre.Text == string.Empty)
     {
         MessageBox.Show("يجب جميع الحقول", "Error");
         users.Focus();
     }
     else
     {
         var     DBonWork = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         DB.User saveuser = new DB.User
         {
             ID       = users.Text,
             PassWord = passward.Text,
             Name     = users_name.Text,
             Degre    = combodegre.Text
         };
         DBonWork.Users.InsertOnSubmit(saveuser);
         DBonWork.SubmitChanges();
         users.Clear();
         users_name.Clear();
         passward.Clear();
         users.Focus();
     }
 }
Exemplo n.º 4
0
 private void SerchAsArea_Click(object sender, EventArgs e)
 {
     if (ComboCentral.Text == string.Empty || Street.Text == string.Empty)
     {
         if (ComboCentral.Text == string.Empty)
         {
             MessageBox.Show("اختار السنترال", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (Street.Text == string.Empty)
         {
             MessageBox.Show("ادخل عنوان للبحث", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         Numcent = pr.GetNumber(ComboCentral.Text);
         var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         var selectdata = from p in DBonWork.Centrals
                          where p.IDcentral == Numcent
                          from d in DBonWork.Cabels
                          where d.IDcentral == p.IDcentral
                          from c in DBonWork.Cabinas
                          where c.IDCable == d.IDCable && c.Area.Contains(Street.Text)
                          select new { p.CentralName, d.CableNumber, c.ODU, c.CABINA, c.Area, d.PunctuationBG, d.PunctuationEN };
         this.dataGridView1.DataSource = null;
         this.dataGridView1.DataSource = selectdata;
     }
     Street.Clear();
 }
Exemplo n.º 5
0
 private void modifay_Click(object sender, EventArgs e)
 {
     if (users.Text == string.Empty || users_name.Text == string.Empty || passward.Text == string.Empty || combodegre.Text == string.Empty)
     {
         MessageBox.Show("يجب ملئ جميع الحقول", "Erorr");
     }
     else
     {
         try
         {
             var I          = dataGridView1.CurrentRow.Index;
             var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             var userupdata = (from c in DBonWork.Users
                               where c.ID.Equals(users.Text)
                               select c).FirstOrDefault();
             userupdata.Name     = users_name.Text;
             userupdata.Degre    = combodegre.Text;
             userupdata.PassWord = passward.Text;
             DBonWork.SubmitChanges();
             dt.RemoveAt(I);
             dataGridView1.DataSource = null;
             dt.Add(userupdata);
             dataGridView1.DataSource = dt;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Erorr");
         }
         users.Clear();
         users_name.Clear();
         passward.Clear();
         combodegre.Text = null;
     }
 }
Exemplo n.º 6
0
 private void SerchAsCabina_Click(object sender, EventArgs e)
 {
     if (ComboCentral.Text == string.Empty || ComboCabina.Text == string.Empty)
     {
         if (ComboCentral.Text == string.Empty)
         {
             MessageBox.Show("اختار السنترال", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (ComboCabina.Text == string.Empty)
         {
             MessageBox.Show("اختار الكابينة", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         var selectdata = from c in DBonWork.Cabinas
                          where c.IDcabina == IDcabina
                          from d in DBonWork.Cabels
                          where d.IDCable == c.IDCable
                          from p in DBonWork.Centrals
                          where p.IDcentral == d.IDcentral
                          select new { p.CentralName, d.CableNumber, c.ODU, c.CABINA, c.Area, d.PunctuationBG, d.PunctuationEN };
         this.dataGridView1.DataSource = selectdata;
     }
 }
Exemplo n.º 7
0
 private void Save_Click(object sender, EventArgs e)
 {
     if (CenteralToSave.Text != string.Empty)
     {
         var        DBonWork    = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         DB.Central SaveCentral = new DB.Central {
             CentralName = CenteralToSave.Text.Trim()
         };
         DBonWork.Centrals.InsertOnSubmit(SaveCentral);
         DBonWork.SubmitChanges();
         var newcentral = (from c in DBonWork.Centrals
                           where c.CentralName.Equals(CenteralToSave.Text)
                           select c).FirstOrDefault();
         Program.InfoCentralList.Add(newcentral);
         this.dataGridView1.DataSource = null;
         this.dataGridView1.DataSource = Program.InfoCentralList;
         comboBox1.Items.Add(CenteralToSave.Text);
         CenteralToSave.Clear();
         CenteralToSave.Focus();
     }
     else
     {
         CenteralToSave.Focus();
     }
 }
Exemplo n.º 8
0
        private void Insert_Click(object sender, EventArgs e)
        {
            var DBonWork  = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var SelecUser = (from user in DBonWork.Users
                             where user.ID == ID.Text
                             select user.Degre).Take(1);

            if (SelecUser.Count() == 0)
            {
                MessageBox.Show("اسم المستخدم او كلمة السر غير صحيحة");
                return;//يقوم بالعودة الى نفس الفورم الحالى عندما يكون شرط الدالة صحيح ولايكمل باقى الكود
            }
            else
            {
                if (SelecUser.Contains("مدير"))
                {
                    Program.UserDgre = true;
                    this.Close();    //يقوم بالخروج عند تسجيل بيانات صحيحة
                }
                else
                {
                    Program.UserDgre = false;
                    this.Close();
                }
            }
        }
        private void ComboCentral_SelectedIndexChanged(object sender, EventArgs e)
        {
            num = pr.GetNumber(ComboCentral.Text);
            ComboCabina.Items.Clear();
            Main.CabinaInfo.Clear();
            var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var selectdata = (from p in DBonWork.Centrals
                              where p.IDcentral == num
                              from d in DBonWork.Cabels
                              where d.IDcentral == p.IDcentral
                              from c in DBonWork.Cabinas
                              where c.IDCable == d.IDCable
                              select new { c.IDcabina, c.CABINA, c.CabinaGeneral }).Distinct();
            var i = from c in selectdata
                    orderby c.CABINA ascending
                    select c;

            if (i.Count() > 0)
            {
                foreach (var X in i)
                {
                    Main.CabinaInfo.Add(X.IDcabina, X.CabinaGeneral);
                    ComboCabina.Items.Add(X.CABINA);
                }
            }
            Street.Focus();
        }
        private void SerchAsStreet_Click(object sender, EventArgs e)
        {
            Main.SpareDPInfo.Clear();
            var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var selectdata = from p in DBonWork.Centrals
                             where p.IDcentral == num
                             from d in DBonWork.Cabels
                             where d.IDcentral == p.IDcentral
                             from c in DBonWork.Cabinas
                             where c.IDCable == d.IDCable
                             from T in DBonWork.DPs
                             where T.IDcabina == c.IDcabina && T.Area.Contains(Street.Text)
                             select new { p.CentralName, d.CableNumber, c.ODU, c.CABINA, d.PunctuationBG, d.PunctuationEN, T.Area, T.DPNumber, T.IDdp, T.DPGeneral };

            this.dataGridView1.DataSource = null;
            this.dataGridView1.DataSource = selectdata;
            if (Main.SpareDPInfo.Count > 0)
            {
                Main.SpareDPInfo.Clear();
            }
            foreach (var item in selectdata)
            {
                Main.SpareDPInfo.Add(item.IDdp, item.DPGeneral);
            }
        }
Exemplo n.º 11
0
 private void ModifyCabel_Click(object sender, EventArgs e)
 {
     if (textBox1.ReadOnly == true)
     {
         var    k = dataGridView2.CurrentRow.Index;
         string x = textBox2.Text, y = textBox3.Text;
         int    b = vrify(num.ToString() + dataGridView2.CurrentRow.Cells[0].Value.ToString());
         if (dataGridView2.CurrentRow.Cells[1].Value.ToString() != x || dataGridView2.CurrentRow.Cells[2].Value.ToString() != y)
         {
             var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             var UpdatCabel = (from c in DBonWork.Cabels
                               where c.IDCable.Equals(b)
                               select c).FirstOrDefault();
             UpdatCabel.PunctuationBG = x;
             UpdatCabel.PunctuationEN = y;
             DBonWork.SubmitChanges();
             ListCabel.RemoveAt(k);
             dataGridView2.DataSource = null;
             ListCabel.Add(UpdatCabel);
             dataGridView2.DataSource = ListCabel;
         }
         groupBox5.Size = new System.Drawing.Size(0, 0);
         comboBox2.Text = KIND.Copper.ToString();
         textBox1.Clear();
         textBox1.ReadOnly = false;
         textBox2.Clear();
         textBox3.Clear();
     }
 }
Exemplo n.º 12
0
 private void ButSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (WindowsAuttentication.Checked == true)
         {
             Properties.Settings.Default.ConctToMaster   = " Data Source='" + ServerName.Text + "';Integrated Security=True;";
             Properties.Settings.Default.ConctToDataBase = "Data Source='" + ServerName.Text + "';Initial Catalog=SmartCentralDB;Integrated Security=True;";
             var   CreatDB = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             LogIn frm     = new LogIn();
             frm.ShowDialog();
             if (Program.UserDgre == true)
             {
                 Properties.Settings.Default.Save();
                 ProcessStartInfo startInfo = new ProcessStartInfo();
                 startInfo.FileName  = @"E:\لغات برمجه\Codes\C#\Applications\Contracts\Contracts\bin\Debug\Contracts.exe";
                 startInfo.Arguments = "SmartCentralDB_Modify WindowsAuttent " + ServerName.Text;
                 Process.Start(startInfo);
             }
             else
             {
                 MessageBox.Show("المستخدم الذى ادخلته لايملك صلاحية تغير اعدادات الاتصال بالسيرفر");
             }
         }
         else
         {
             Properties.Settings.Default.ConctToMaster = " Data Source='" + ServerName.Text.Trim() + "'Integrated Security= false;Uesr ID=" +
                                                         UserNameAutt.Text.Trim() + "';Password='******';";
             Properties.Settings.Default.ConctToDataBase = "Data Source='" + ServerName.Text + "';Initial Catalog=SmartCentralDB;Integrated Security= false;Uesr ID=" +
                                                           UserNameAutt.Text.Trim() + "';Password='******';";
             var   CreatDB = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             LogIn frm     = new LogIn();
             frm.ShowDialog();
             if (Program.UserDgre == true)
             {
                 Properties.Settings.Default.Save();
                 ProcessStartInfo startInfo = new ProcessStartInfo();
                 startInfo.FileName  = @"E:\لغات برمجه\Codes\C#\Applications\Contracts\Contracts\bin\Debug\Contracts.exe";
                 startInfo.Arguments = "SmartCentralDB_Modify SQLServerAuttent " + ServerName.Text +
                                       " " + UserNameAutt.Text + " " + PassWordAutt;
                 Process.Start(startInfo);
             }
             else
             {
                 MessageBox.Show("المستخدم الذى ادخلته لايملك صلاحية تغير اعدادات الاتصال بالسيرفر");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Erorr");
     }
     ServerName.Clear();
     UserNameAutt.Clear();
     PassWordAutt.Clear();
 }
Exemplo n.º 13
0
        private void users_Validated(object sender, EventArgs e)
        {
            var DBonWork = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var verify   = from c in DBonWork.Users
                           where c.ID == users.Text.Trim()
                           select c;

            if (verify.Count() > 0)
            {
                MessageBox.Show("هذا المستخدم موجود بالفعل", "Error");
                users.Focus();
            }
        }
Exemplo n.º 14
0
        public UserBesines()
        {
            InitializeComponent();
            var DBonWork = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var userinf  = from c in DBonWork.Users
                           select c;

            foreach (var x in userinf)
            {
                dt.Add(x);
            }
            dataGridView1.DataSource = dt;
        }
Exemplo n.º 15
0
 public void fillinfocentral()
 {
     try
     {
         var DBonWork      = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         var SelectCentral = from c in DBonWork.Centrals select c;
         foreach (var item in SelectCentral)
         {
             Program.InfoCentralList.Add(item);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void SerchAsDP_Click(object sender, EventArgs e)
        {
            int ID         = pr.DPExisting(num.ToString() + ComboCabina.Text + ComboDP.Text);
            var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var selectdata = from p in DBonWork.DPs
                             where p.IDdp == ID
                             from B in DBonWork.Cabinas
                             where B.IDcabina == p.IDcabina
                             from D in DBonWork.Cabels
                             where D.IDCable == B.IDCable
                             from c in DBonWork.Centrals
                             where c.IDcentral == D.IDcentral
                             select new { c.CentralName, D.CableNumber, B.ODU, B.CABINA, p.DPNumber, p.Area, D.PunctuationBG, D.PunctuationEN };

            this.dataGridView1.DataSource = selectdata;
        }
Exemplo n.º 17
0
 private void SaveBt_Click(object sender, EventArgs e)
 {
     if (ComboCentral.Text == string.Empty || ComboCabina.Text == string.Empty || DPNumber.Text == string.Empty || AreaDP.Text == string.Empty)
     {
         if (ComboCentral.Text == string.Empty)
         {
             MessageBox.Show("اختار السنترال", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (ComboCabina.Text == string.Empty)
         {
             MessageBox.Show("اختار الكابينة", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (DPNumber.Text == string.Empty)
         {
             MessageBox.Show("حدد رقم البكس", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (AreaDP.Text == string.Empty)
         {
             MessageBox.Show("ادخل عنوان البكس", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         try
         {
             string dpGeneral = Numcent.ToString() + ComboCabina.Text + DPNumber.Text;
             var    DBonWork  = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             DB.DP  SaveDP    = new DB.DP
             {
                 IDcabina  = Numcabina,
                 Area      = AreaDP.Text.Trim(),
                 DPNumber  = DPNumber.Text.Trim(),
                 DPGeneral = dpGeneral
             };
             DBonWork.DPs.InsertOnSubmit(SaveDP);
             DBonWork.SubmitChanges();
             MyList.Add(DPNumber.Text.Trim());
             AreaDP.Clear();
             DPNumber.Clear();
             DPNumber.Focus();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 18
0
        private void ComboCabina_SelectedIndexChanged(object sender, EventArgs e)
        {
            Numcabina = pr.CabinaExisting(ComboCabina.Text);
            MyList.Clear();
            var DBonWork = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var SelecDP  = (from D in DBonWork.DPs
                            where D.IDcabina == Numcabina
                            select D.DPNumber).Distinct();

            if (SelecDP.Count() > 0)
            {
                foreach (var item in SelecDP)
                {
                    MyList.Add(item);
                }
            }
            DPNumber.Focus();
        }
Exemplo n.º 19
0
        private void button1_Click(object sender, EventArgs e)
        {
            var DBonWork = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);

            try
            {
                if (button1.Text == "حفظ")
                {
                    if (combocent.Text == string.Empty || ComboType.Text == string.Empty || CabinaCabel.Text == string.Empty || tetarea.Text == string.Empty)
                    {
                        MessageBox.Show("يجب ملئ الحقول اولا", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        combocent.Focus();
                    }
                    else
                    {
                        DB.Cabina SaveCabina = new DB.Cabina
                        {
                            IDCable       = NumCabel,
                            CABINA        = CabinaCabel.Text,
                            Area          = tetarea.Text.Trim(),
                            CabinaGeneral = NumCentral.ToString() + CabinaCabel.Text,
                            ODU           = ODU.Text
                        };
                        DBonWork.Cabinas.InsertOnSubmit(SaveCabina);
                        DBonWork.SubmitChanges();
                        MyList.Add(NumCentral.ToString() + CabinaCabel.Text);
                        tetarea.Clear();
                        CabinaCabel.Focus();
                        CabinaCabel.SelectionStart  = 0;
                        CabinaCabel.SelectionLength = CabinaCabel.Text.Length;
                    }
                }
                if (button1.Text == "تحديث")
                {
                    NumCabel = pr.CabelExisting(ComboType.Text);
                    pr.Update_Cabinas(NumCabina, NumCabel, tetarea.Text, ODU.Text);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 20
0
 private void users_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         var DBonWork = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         var verify   = from c in DBonWork.Users
                        where c.ID == users.Text.Trim()
                        select c;
         if (verify.Count() > 0)
         {
             MessageBox.Show("هذا المستخدم موجود بالفعل", "Error");
             users.Focus();
         }
         else
         {
             users_name.Focus();
         }
     }
 }
Exemplo n.º 21
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();
     }
 }
Exemplo n.º 22
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            num = pr.GetNumber(comboBox1.Text);
            textBox1.Clear();
            textBox2.Clear();
            textBox3.Clear();
            ListCabel.Clear();
            var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var SelectCabl = (from c in DBonWork.Cabels
                              where c.IDcentral == num
                              select c).Distinct();

            foreach (var x in SelectCabl)
            {
                ListCabel.Add(x);
            }
            dataGridView2.DataSource = null;
            dataGridView2.DataSource = ListCabel;
            textBox1.Focus();
        }
Exemplo n.º 23
0
 private void DeletCabel_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.ReadOnly == true)
         {
             int k          = dataGridView2.CurrentRow.Index;
             int b          = vrify(num.ToString() + dataGridView2.CurrentRow.Cells[0].Value.ToString());
             var DBonWork   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             var deletcabel = (from c in DBonWork.Cabels
                               where c.IDCable.Equals(b)
                               select c).FirstOrDefault();
             DBonWork.Cabels.DeleteOnSubmit(deletcabel);
             DBonWork.SubmitChanges();
             ListCabel.RemoveAt(k);
             dataGridView2.DataSource = null;
             dataGridView2.DataSource = ListCabel;
             groupBox5.Size           = new System.Drawing.Size(0, 0);
             textBox1.ReadOnly        = false;
             textBox1.Clear();
             textBox2.Clear();
             textBox3.Clear();
         }
     }
     catch (SqlException ex)
     {
         if (ex.Number == 547)
         {
             MessageBox.Show("الكابل يحتوى على بيانات يجب حذفهااولا");
         }
         else
         {
             MessageBox.Show(ex.ToString());
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.ToString());
     }
 }
        private void ComboCabina_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboDP.Items.Clear();
            Main.DPInfo.Clear();
            int j        = pr.CabinaExisting(num.ToString() + ComboCabina.Text);
            var DBonWork = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
            var SelecDP  = from D in DBonWork.DPs
                           where D.IDcabina == j
                           select new { D.IDdp, D.DPGeneral, D.DPNumber };
            var i = from c in SelecDP
                    orderby c.DPNumber ascending
                    select c;

            if (i.Count() > 0)
            {
                foreach (var item in SelecDP)
                {
                    ComboDP.Items.Add(item.DPNumber);
                    Main.DPInfo.Add(item.IDdp, item.DPGeneral);
                }
            }
            var selectdata = from p in DBonWork.DPs
                             where p.IDcabina == j
                             from B in DBonWork.Cabinas
                             where B.IDcabina == p.IDcabina
                             from D in DBonWork.Cabels
                             where D.IDCable == B.IDCable
                             from c in DBonWork.Centrals
                             where c.IDcentral == D.IDcentral
                             select new { c.CentralName, D.CableNumber, B.ODU, B.CABINA, p.DPNumber, p.Area, D.PunctuationBG, D.PunctuationEN };
            var t = from c in selectdata
                    orderby c.DPNumber ascending
                    select c;

            this.dataGridView1.DataSource = null;
            this.dataGridView1.DataSource = t;
            ComboDP.Focus();
        }
Exemplo n.º 25
0
 private void SaveCabel_Click(object sender, EventArgs e)
 {
     if (textBox1.ReadOnly != true)
     {
         string ID = comboBox2.Text == KIND.Copper.ToString() ? textBox1.Text : ("M" + textBox1.Text);
         if (vrify(num.ToString() + ID) == 0)
         {
             var      DBonWork    = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             DB.Cabel CabelInsert = new DB.Cabel {
                 IDcentral = num, CableNumber = ID, CabelGenral = num.ToString() + ID, PunctuationBG = textBox2.Text, PunctuationEN = textBox3.Text
             };
             DBonWork.Cabels.InsertOnSubmit(CabelInsert);
             DBonWork.SubmitChanges();
             var newcabel = (from c in DBonWork.Cabels
                             where c.IDcentral == num && c.CableNumber == ID
                             select c).FirstOrDefault();
             ListCabel.Add(newcabel);
             groupBox5.Size           = new System.Drawing.Size(0, 0);
             comboBox2.Text           = KIND.Copper.ToString();
             dataGridView2.DataSource = null;
             dataGridView2.DataSource = ListCabel;
             textBox1.Clear();
             textBox2.Clear();
             textBox3.Clear();
             textBox1.Focus();
             textBox1.SelectionStart  = 0;
             textBox1.SelectionLength = textBox1.Text.Length;
         }
         else
         {
             MessageBox.Show("هذا الكابل من ضمن كابلات السنترال الحالى");
             textBox1.Focus();
             textBox1.SelectionStart  = 0;
             textBox1.SelectionLength = textBox1.Text.Length;
         }
     }
 }
Exemplo n.º 26
0
 private void initialToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         PublicClass pr      = new PublicClass();
         var         CreatDB = new DB.SmartCentralDB(Properties.Settings.Default.ConctToMaster);
         if (!CreatDB.DatabaseExists())
         {
             CreatDB.CreateDatabase();
             var InDB   = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
             var userdb = from us in InDB.Users
                          where us.ID == "Admin"
                          select us;
             if (userdb.Count() == 0)
             {
                 DB.User first = new DB.User {
                     ID = "Admin", PassWord = "******", Name = "Admin", Degre = "مدير"
                 };
                 InDB.Users.InsertOnSubmit(first);
                 InDB.SubmitChanges();
             }
             foreach (string item in CreateProc.createproctural)
             {
                 pr.InsertQury(item);
             }
             MessageBox.Show("تم تكوين قاعدة البيانات بنجاح");
         }
         else
         {
             MessageBox.Show(" قاعدة البيانات مهيئة بالفعل");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n خطاء اثناء تكوين قاعدة البيانات اضبط اعدادات الاتصال بالخادم ");
     }
 }
Exemplo n.º 27
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("ادخل اسم السنترال");
     }
 }
Exemplo n.º 28
0
 private void combocent_SelectedIndexChanged(object sender, EventArgs e)
 {
     NumCentral = pr.GetNumber(combocent.Text);
     if (combocent.Text != CentrlName)
     {
         CentrlName = combocent.Text;
         Main.CabelInfo.Clear();
         ComboType.Items.Clear();
         MyList.Clear();
         var DBonWork       = new DB.SmartCentralDB(Properties.Settings.Default.ConctToDataBase);
         var SelectAllCabel = (from c in DBonWork.Cabels
                               where c.IDcentral == NumCentral
                               select new { c.IDCable, c.CableNumber });
         foreach (var item in SelectAllCabel)
         {
             Main.CabelInfo.Add(item.IDCable, item.CableNumber);
             ComboType.Items.Add(item.CableNumber);
         }
         var j = from c in DBonWork.Cabels
                 where c.IDcentral == NumCentral
                 from p in DBonWork.Cabinas
                 where p.IDCable == c.IDCable
                 select p.CabinaGeneral;
         foreach (var item in j)
         {
             MyList.Add(item);
         }
     }
     if (button1.Text == "حفظ")
     {
         CabinaCabel.Clear();
     }
     label6.Text = "";
     ODU.Clear();
     ComboType.Focus();
 }