Exemplo n.º 1
0
        private void ButtonIz_Click(object sender, RoutedEventArgs e)
        {
            WinIz dobDriver = new WinIz();

            if (DataGridVoditeli.Items.Count > 0)
            {
                var index = DataGridVoditeli.SelectedItem;
                if (index != null)
                {
                    int id = int.Parse((DataGridVoditeli.SelectedCells[0].Column.GetCellContent(index) as TextBlock).Text);
                    using (GIBDDContainer db = new GIBDDContainer())
                    {
                        Drivers driver = db.Drivers.Find(id);
                        dobDriver.TextBoxIden.Text  = driver.Id.ToString();
                        dobDriver.TextBoxFam.Text   = driver.Lastname;
                        dobDriver.TextBoxName.Text  = driver.Name;
                        dobDriver.TextBoxMid.Text   = driver.Middlename;
                        dobDriver.TextBoxSer.Text   = driver.PassportSerial.ToString();
                        dobDriver.TextBoxNum.Text   = driver.PassportNumber.ToString();
                        dobDriver.TextBoxReg.Text   = driver.Address;
                        dobDriver.TextBoxPro.Text   = driver.Address;
                        dobDriver.TextBoxRab.Text   = driver.Company;
                        dobDriver.TextBoxDol.Text   = driver.Jobname;
                        dobDriver.TextBoxPhone.Text = driver.Phone;
                        dobDriver.TextBoxEmail.Text = driver.Email;
                        string photo = "C:\\Users\\3курс\\Desktop\\мдк 01.01\\01.02\\GIBDD\\bin\\Debug\\photo\\" + driver.Photo;
                        dobDriver.TextBoxZam.Text = driver.Description;

                        if (dobDriver.ShowDialog().HasValue)
                        {
                            return;
                        }

                        driver.Lastname       = dobDriver.TextBoxFam.Text;
                        driver.Name           = dobDriver.TextBoxName.Text;
                        driver.Middlename     = dobDriver.TextBoxMid.Text;
                        driver.PassportSerial = int.Parse(dobDriver.TextBoxSer.Text);
                        driver.PassportNumber = int.Parse(dobDriver.TextBoxNum.Text);
                        driver.Address        = dobDriver.TextBoxReg.Text;
                        driver.Address        = dobDriver.TextBoxPro.Text;
                        driver.Company        = dobDriver.TextBoxRab.Text;
                        driver.Jobname        = dobDriver.TextBoxDol.Text;
                        driver.Phone          = dobDriver.TextBoxPhone.Text;
                        driver.Email          = dobDriver.TextBoxEmail.Text;
                        driver.Description    = dobDriver.TextBoxZam.Text;
                        db.SaveChanges();
                    }
                }
                FillTable();
            }
        }
Exemplo n.º 2
0
 private void ButtonZap_Click(object sender, RoutedEventArgs e)
 {
     if (TextBoxFam.Text.Length != 0)
     {
         if (TextBoxName.Text.Length != 0)
         {
             if (TextBoxMid.Text.Length != 0)
             {
                 if (TextBoxSer.Text.Length != 0 || TextBoxNum.Text.Length != 0)
                 {
                     if (TextBoxReg.Text.Length != 0 || TextBoxPro.Text.Length != 0)
                     {
                         if (TextBoxPhone.Text.Length != 0)
                         {
                             if (TextBoxEmail.Text.Length != 0 && CheckEmail(TextBoxEmail.Text) == true)
                             {
                                 if (path != null)
                                 {
                                     using (GIBDDContainer1 db = new GIBDDContainer1())
                                     {
                                         Drivers driver = new Drivers();
                                         driver.Id             = int.Parse(TextBoxIden.Text);
                                         driver.Name           = TextBoxName.Text;
                                         driver.Lastname       = TextBoxFam.Text;
                                         driver.Middlename     = TextBoxMid.Text;
                                         driver.PassportSerial = int.Parse(TextBoxSer.Text);
                                         driver.PassportNumber = int.Parse(TextBoxNum.Text);
                                         driver.Postcode       = int.Parse(TextBoxIden.Text);
                                         driver.Address        = TextBoxReg.Text;
                                         driver.AddressLife    = TextBoxPro.Text;
                                         driver.Company        = TextBoxRab.Text;
                                         driver.Jobname        = TextBoxDol.Text;
                                         driver.Phone          = TextBoxPhone.Text;
                                         driver.Email          = TextBoxEmail.Text;
                                         driver.Description    = TextBoxZam.Text;
                                         driver.Photo          = path.Substring(path.LastIndexOf("\\") + 1);
                                         db.Drivers.Add(driver);
                                         db.SaveChanges();
                                         MessageBox.Show("Полььзователь зарегестрирован");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 private void ButtonZap_Click(object sender, RoutedEventArgs e)
 {
     if (TextBoxVinNumAvto.Text.Length != 0)
     {
         if (TextBoxMarka.Text.Length != 0)
         {
             if (TextBoxModel.Text.Length != 0)
             {
                 if (TextBoxTeipTransSred.Text.Length != 0 || TextBoxCategoriesTransSred.Text.Length != 0)
                 {
                     if (TextBoxGodV.Text.Length != 0 || TextBoxNumColor.Text.Length != 0)
                     {
                         if (TextBoxVesAvto.Text.Length != 0 || TextBoxTipDvig.Text.Length != 0)
                         {
                             if (TextBoxVesAvtoKG.Text.Length != 0 || TextBoxTipPrivod.Text.Length != 0)
                             {
                                 if (path != null)
                                 {
                                     Drivers driver = new Drivers();
                                     driver.Id             = int.Parse(TextBoxIden.Text);
                                     driver.Name           = TextBoxName.Text;
                                     driver.Lastname       = TextBoxFam.Text;
                                     driver.Middlename     = TextBoxMid.Text;
                                     driver.PassportSerial = int.Parse(TextBoxSer.Text);
                                     driver.PassportNumber = int.Parse(TextBoxNum.Text);
                                     driver.Postcode       = int.Parse(TextBoxIden.Text);
                                     driver.Address        = TextBoxReg.Text;
                                     driver.AddressLife    = TextBoxPro.Text;
                                     driver.Company        = TextBoxRab.Text;
                                     driver.Jobname        = TextBoxDol.Text;
                                     driver.Phone          = TextBoxPhone.Text;
                                     driver.Email          = TextBoxEmail.Text;
                                     driver.Description    = TextBoxZam.Text;
                                     driver.Photo          = path.Substring(path.LastIndexOf("\\") + 1);
                                     db.Drivers.Add(driver);
                                     db.SaveChanges();
                                     MessageBox.Show("Транспортное средство добавлено!");
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }