コード例 #1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (txtPass.Text != txtRePass.Text)
            {
                MessageBox.Show("كلمة المرور غير متطابقة", "Super market", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtRePass.Focus();
                return;
            }

            if (txtUserId.Text == string.Empty || txtUserName.Text == string.Empty || txtPass.Text == string.Empty ||
                txtFullName.Text == string.Empty || comboType.SelectedItem == null)
            {
                MessageBox.Show("احدي الحقول فارغة", "super market", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                if (State == "Add")
                {
                    ClassUser.AddUser(Convert.ToInt32(txtUserId.Text), txtUserName.Text, txtPass.Text, txtFullName.Text, dateUser.Value, Convert.ToInt32(comboType.SelectedValue));
                    MessageBox.Show("تم اضافة المستخدم", "super market", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BtnAdd.Enabled = false;
                    BtnNew.Enabled = false;
                }

                if (State == "Update")
                {
                    int id = Convert.ToInt32(this.txtUserId.Text);

                    ClassUser.UpdateUser(txtUserName.Text, txtPass.Text, txtFullName.Text, dateUser.Value, Convert.ToInt32(comboType.SelectedValue), id);
                    MessageBox.Show("تم تعديل المستخدم", "super market", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BtnAdd.Enabled = false;
                    BtnNew.Enabled = false;
                    this.Close();
                }
            }
            catch
            {
                return;
            }
        }