//Save EVent Creat Manager//
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (_isUpdate)
            {
                DialogResult r = MessageBox.Show("Əminsinizmi.?", "Yenilemeye", MessageBoxButtons.YesNo);
                if (r == DialogResult.Yes)
                {
                    _manager.Name    = TxtName.Text;
                    _manager.Surname = TxtSurname.Text;
                    _manager.Age     = Convert.ToInt32(TxtAge.Text);
                    _manager.Phone   = TxtPhone.Text;
                    _manager.Email   = TxtEmail.Text;
                    MessageBox.Show("Melumat deisildi");
                    _managerDal.Update(_manager);
                    AddManager?.Invoke(_manager, new EventArgs());
                }
            }
            else
            {
                if (!this.CheckInput())
                {
                    MessageBox.Show("Zehmet olmasa xanalari doldurun !", "Xəbərdarlıq", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!TxtAge.Text.IsNumber())
                {
                    MessageBox.Show("Yasi duzgun qeyd edin !", "Xəbərdarlıq", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!TxtEmail.Text.IsEmail())
                {
                    MessageBox.Show("Emaili duzgun qeyd edin !", "Xəbərdarlıq", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (_managerDal.GetAll().Any(m => m.Email == TxtEmail.Text))
                {
                    MessageBox.Show("Bu email artiq movcuddur !", "Xəbərdarlıq", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!TxtPhone.Text.IsNumber())
                {
                    MessageBox.Show("Duzgun nomre qeyd edin !", "Xəbərdarlıq", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                Manager manager = new Manager
                {
                    Name     = TxtName.Text,
                    Surname  = TxtSurname.Text,
                    Age      = Convert.ToInt32(TxtAge.Text),
                    Email    = TxtEmail.Text,
                    Password = Crypto.HashPassword(TxtPassword.Text),
                    Phone    = TxtPhone.Text,
                    Status   = true
                };
                _managerDal.Create(manager);
                MessageBox.Show("Isci elave edildi");
                AddManager?.Invoke(manager, new EventArgs());
            }
            this.Close();
        }
示例#2
0
 /// <summary>
 /// 更新Model数据,根据id进行修改
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(Manager model)
 {
     return(dal.Update(model) == 1);
 }