Beispiel #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(tbxEye.Text))
         {
             errorProviderEye.SetError(tbxEye, "Add Eye Color!");
             return;
         }
         else
         {
             EyeColor eye = new EyeColor
             {
                 ColorName = tbxEye.Text
             };
             db.EyeColors.Add(eye);
             db.SaveChanges();
             updateInfo();
             clearTxt();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please try again after 2 minutes!");
         File.AppendAllText(path, "\n" + ex + ":" + DateTime.Now);
         return;
     }
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(tbxRoles.Text))
         {
             errorProviderRoles.SetError(tbxRoles, "Add Roles Type!");
             return;
         }
         else
         {
             Role role = new Role
             {
                 Name = tbxRoles.Name
             };
             db.Roles.Add(role);
             db.SaveChanges();
             updateInfo();
             clearTxt();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please try again after 2 minutes!");
         File.AppendAllText(path, "\n" + ex + ":" + DateTime.Now);
         return;
     }
 }
Beispiel #3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(tbxMarital.Text))
         {
             errorProviderMarital.SetError(tbxMarital, "Add Marital Status!");
             return;
         }
         else
         {
             MaritalStatu marital = new MaritalStatu
             {
                 Name = tbxMarital.Text
             };
             db.MaritalStatus.Add(marital);
             db.SaveChanges();
             updateInfo();
             clearTxt();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please try again after 2 minutes!");
         File.AppendAllText(path, "\n" + ex + ":" + DateTime.Now);
         return;
     }
 }
Beispiel #4
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         string name = tbxNation.Text;
         if (string.IsNullOrWhiteSpace(tbxNation.Text))
         {
             errorProviderNation.SetError(tbxNation, "Add Nation Type!");
             return;
         }
         else
         {
             Nationality nationality = new Nationality
             {
                 Name = name
             };
             db.Nationalities.Add(nationality);
             db.SaveChanges();
             updateInfo();
             clearTxt();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please try again after 2 minutes!");
         File.AppendAllText(path, "\n" + ex + ":" + DateTime.Now);
         return;
     }
 }
        private void btnRemove_Click(object sender, EventArgs e)
        {
            string name = tbxBlood.Text;

            if (string.IsNullOrWhiteSpace(tbxBlood.Text))
            {
                errorProviderBlood.SetError(tbxBlood, "Choose Blood Type");
                return;
            }
            else
            {
                selectedBlood.DeletedDate = DateTime.Now;
                db.SaveChanges();
                updateInfo();
                btnAdd.Enabled = true;
                clearTxt();
            }
        }
Beispiel #6
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(tbxName.Text))
         {
             errorProviderMain.SetError(tbxName, "Enter Name!");
             return;
         }
         if (string.IsNullOrWhiteSpace(tbxSurname.Text))
         {
             errorProviderMain.SetError(tbxSurname, "Enter Surname!");
             return;
         }
         if (string.IsNullOrWhiteSpace(tbxSeries.Text))
         {
             errorProviderMain.SetError(tbxSeries, "Enter Series!");
             return;
         }
         if (string.IsNullOrWhiteSpace(tbxNumber.Text))
         {
             errorProviderMain.SetError(tbxNumber, "Enter Number!");
             return;
         }
         if (string.IsNullOrWhiteSpace(tbxIssueAuthority.Text))
         {
             errorProviderMain.SetError(tbxIssueAuthority, "Enter Authority!");
             return;
         }
         else
         {
             ComboItem nation    = cbxNationality.SelectedItem as ComboItem;
             ComboItem blood     = cbxBloodGroup.SelectedItem as ComboItem;
             ComboItem military  = cbxMilitary.SelectedItem as ComboItem;
             ComboItem marital   = cbxMarital.SelectedItem as ComboItem;
             ComboItem eye       = cbxEyeColor.SelectedItem as ComboItem;
             ComboItem gender    = cbxGender.SelectedItem as ComboItem;
             Person    newPerson = new Person
             {
                 FirstName        = tbxName.Text,
                 LastName         = tbxSurname.Text,
                 FatherName       = tbxFatherName.Text,
                 BirthPlace       = tbxBirthPlace.Text,
                 BirthofDate      = dtpBirthDate.Value,
                 EyeColorID       = eye.Value,
                 NationalityID    = nation.Value,
                 BloodGroupID     = blood.Value,
                 MaritalStatusID  = marital.Value,
                 MilitaryStatusID = military.Value,
                 GenderID         = gender.Value,
                 Height           = (byte)nudHeight.Value,
                 LivingPlace      = tbxLivingPlace.Text,
                 IssueDate        = dtpIssueDate.Value,
                 ExpiryDate       = dtpExpiryDate.Value,
                 Series           = tbxSeries.Text,
                 Number           = tbxNumber.Text,
                 IssuingAuthority = tbxIssueAuthority.Text
             };
             db.People.Add(newPerson);
             db.SaveChanges();
             string path = Path.Combine(folder, newPerson.ID + ".jpg");
             pictureBox1.Image.Save(path);
             updateInfo();
             clearTxt();
             pictureBox1.Image = null;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please try again after 2 minutes!");
         File.AppendAllText(path2, "\n" + ex + ":" + DateTime.Now);
         return;
     }
 }