Beispiel #1
0
 private void AddPeopleBtn_Click(object sender, EventArgs e)
 {
     if (PeopleId > 0)
     {
         People temp = peopleRepository.GetPeople(PeopleId);
         temp.AccountNumber = AccountNumberTxt.Text;
         temp.Name          = NameTxt.Text;
         temp.Family        = FamilyTxt.Text;
         temp.Tell          = TellTex.Text;
         temp.Username      = UsernameTxt.Text;
         temp.Password      = PassTxt.Text;
         string result = CheckRepository.CheckPeople(temp, true);
         if (result == "")
         {
             peopleRepository.Update();
             MessageBox.Show("عملیات با موفقیت انجام شد!", "موفق", MessageBoxButtons.OK);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         else
         {
             ErrorLbl.Text = result;
         }
     }
     else
     {
         CodeMelliTxt.Enabled = true;
         People temp = new People()
         {
             Name          = NameTxt.Text,
             Family        = FamilyTxt.Text,
             Tell          = TellTex.Text,
             CodeMelli     = CodeMelliTxt.Text,
             AccountNumber = AccountNumberTxt.Text,
             Username      = UsernameTxt.Text,
             Password      = PassTxt.Text,
             ClinicId      = clinicId
         };
         string result = CheckRepository.CheckPeople(temp, false);
         if (result == "")
         {
             peopleRepository.AddPeople(temp);
             MessageBox.Show("عملیات با موفقیت انجام شد!", "موفق", MessageBoxButtons.OK);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         else
         {
             ErrorLbl.Text = result;
         }
     }
 }