예제 #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            String      SUN            = txtBoxScreenUserName.Text.Trim();
            String      UEA            = txtBoxUserEmail.Text.Trim();
            String      Pwd            = "12345";
            int         URID           = 1;
            UserAccount userAccountObj = new UserAccount
            {
                ScreenUserName   = SUN,
                UserEmailAddress = UEA,
                Password         = Pwd,
                UserRoleID       = URID,
            };
            String ErrorMsg = "!..هذا الحقل مطلوب";

            if (UserInterfaceValidatorObj.TxtBoxValidator(SUN) == 1)
            {
                txtBoxScreenUserName.Focus();
                TxtBoxerrorProvider.SetError(txtBoxScreenUserName, ErrorMsg);
                txtBoxScreenUserName.FlatAppearance.BorderSize  = 2;
                txtBoxScreenUserName.FlatAppearance.BorderColor = Color.Red;
                txtBoxScreenUserName.BackColor = ColorTranslator.FromHtml("#ff0033");
                txtBoxScreenUserName.ForeColor = ColorTranslator.FromHtml("#ffcdc9");
                txtBoxScreenUserName.Font      = new Font("", 10, FontStyle.Bold);
                return;
            }
            else if (UserInterfaceValidatorObj.EmailValidator(UEA))
            {
                TxtBoxerrorProvider.Clear();
                txtBoxScreenUserName.FlatAppearance.BorderSize  = 1;
                txtBoxScreenUserName.FlatAppearance.BorderColor = ColorTranslator.FromHtml("#252526");
                txtBoxScreenUserName.BackColor = ColorTranslator.FromHtml("#f0f0f0");
                txtBoxScreenUserName.ForeColor = ColorTranslator.FromHtml("#000000");
                txtBoxScreenUserName.Font      = new Font("", 9, FontStyle.Regular);
                try
                {
                    ClsUserAccountsServices.Insert(userAccountObj);
                    MessageBox.Show("تم تسجيل البيانات بنجاح", "رسـالـة تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch
                {
                    MessageBox.Show("حدثت مشكلة أثناء تخزين البيانات", "رسـالـة تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show(" !..غـير صحيح   " + UEA + "  :هذا الإدخـال", "رسـالـة تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        private async void BtnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TxtLoginUserName.Text.Trim()) || string.IsNullOrWhiteSpace(TxtLoginPassword.Text.Trim()))
            {
                lblMsgBox.Text      = ClsAppMsgs.EmptyFielsAlertMsg;
                lblMsgBox.BackColor = ColorTranslator.FromHtml("#ffedf6");
                lblMsgBox.ForeColor = ColorTranslator.FromHtml("#d20051");
                BtnLogin.Focus();
                lblMsgBox.Visible = true;
                await Task.Delay(3000);

                lblMsgBox.Visible = false;
                return;
            }
            else
            {
                String      TxtBoxUserEmailValue = TxtLoginUserName.Text.Trim();
                String      TxtBoxPasswordValue  = TxtLoginPassword.Text.Trim();
                UserAccount userAccountObj       = new UserAccount
                {
                    UserEmailAddress = TxtBoxUserEmailValue,
                    Password         = TxtBoxPasswordValue,
                };
                try
                {
                    // ClsUserAccountsServices.Insert(userAccountObj);
                    ClsUserAccountsServices.UserAccountExist(userAccountObj);
                }
                catch
                {
                    lblMsgBox.Text      = ClsAppMsgs.LoginErrorOccurredMsg;
                    lblMsgBox.BackColor = ColorTranslator.FromHtml("#ffedf6");
                    lblMsgBox.ForeColor = ColorTranslator.FromHtml("#d20051");
                    lblMsgBox.Visible   = true;
                    BtnLogin.Focus();
                    await Task.Delay(3000);

                    lblMsgBox.Visible = false;
                }
            }
            if (!ClsUserAccountsServices.EmailAlreadyExists)
            {
                // UserEmailNotExistsMsg
                lblMsgBox.Text      = ClsAppMsgs.UserEmailNotExistsMsg;
                lblMsgBox.BackColor = ColorTranslator.FromHtml("#fff5cc");
                lblMsgBox.ForeColor = ColorTranslator.FromHtml("#856404");
                lblMsgBox.Visible   = true;
                BtnLogin.Focus();
                await Task.Delay(3000);

                lblMsgBox.Visible = false;
                ClsUserAccountsServices.EmailAlreadyExists = false;
                return;
            }
            else
            {
                if (ClsUserAccountsServices.UserCanLogin == true)
                {
                    ClsUserAccountsServices.UserCanLogin = false;
                    lblMsgBox.Text      = "دخــــــول";
                    lblMsgBox.BackColor = ColorTranslator.FromHtml("#deffef");
                    lblMsgBox.ForeColor = ColorTranslator.FromHtml("#009e52");
                    lblMsgBox.Visible   = true;
                    BtnLogin.Focus();
                    await Task.Delay(3000);

                    lblMsgBox.Visible = false;
                    //return;
                    Form frmMain = new FrmMainApp();
                    frmMain.Show();
                    this.Visible = false;
                    this.Hide();
                    //this.Close();
                    //this.Dispose();
                }
                else
                {
                    lblMsgBox.Text      = ClsAppMsgs.UserCanNotLoginMsg;
                    lblMsgBox.BackColor = ColorTranslator.FromHtml("#fff5cc");
                    lblMsgBox.ForeColor = ColorTranslator.FromHtml("#856404");
                    lblMsgBox.Visible   = true;
                    BtnLogin.Focus();
                    await Task.Delay(3000);

                    lblMsgBox.Visible = false;
                    ClsUserAccountsServices.EmailAlreadyExists = false;
                    ClsUserAccountsServices.UserCanLogin       = false;
                    return;
                }
            }
        }
예제 #3
0
        private async void BtnReg_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TxtBoxScreenUserName.Text.Trim()) || string.IsNullOrWhiteSpace(TxtBoxUserEmail.Text.Trim()) || CombBoxUserRole.SelectedItem == null || CombBoxUserRole.SelectedIndex == -1 || string.IsNullOrWhiteSpace(TxtBoxPassword.Text.Trim()) || string.IsNullOrWhiteSpace(TxtBoxPasswordConfirm.Text.Trim()))
            {
                lblMsgBox.Text      = ClsAppMsgs.EmptyFielsAlertMsg;
                lblMsgBox.BackColor = ColorTranslator.FromHtml("#ffedf6");
                lblMsgBox.ForeColor = ColorTranslator.FromHtml("#d20051");
                lblMsgBox.Visible   = true;
                await Task.Delay(3000);

                lblMsgBox.Visible = false;
                return;
            }
            if (TxtBoxPasswordConfirm.Text.Trim() != TxtBoxPassword.Text.Trim())
            {
                TxtBoxPasswordConfirmCheck();
                return;
            }
            String      TxtBoxScreenUserNameValue = TxtBoxScreenUserName.Text.Trim();
            String      TxtBoxUserEmailValue      = TxtBoxUserEmail.Text.Trim();
            String      TxtBoxPasswordValue       = TxtBoxPassword.Text.Trim();
            int         CombBoxUserRoleValueID    = CombBoxUserRole.SelectedIndex + 1;
            UserAccount userAccountObj            = new UserAccount
            {
                ScreenUserName   = TxtBoxScreenUserNameValue,
                UserEmailAddress = TxtBoxUserEmailValue,
                Password         = TxtBoxPasswordValue,
                UserRoleID       = CombBoxUserRoleValueID,
            };

            try
            {
                ClsUserAccountsServices.Insert(userAccountObj);
                if (ClsUserAccountsServices.UserNameAlreadyExists)
                {
                    // UserNameAlreadyExistsMsg
                    lblMsgBox.Text      = ClsAppMsgs.UserNameAlreadyExistsMsg;
                    lblMsgBox.BackColor = ColorTranslator.FromHtml("#fff5cc");
                    lblMsgBox.ForeColor = ColorTranslator.FromHtml("#856404");
                    lblMsgBox.Visible   = true;
                    TxtBoxUserEmail.Focus();
                    await Task.Delay(3000);

                    lblMsgBox.Visible = false;
                    ClsUserAccountsServices.UserNameAlreadyExists = false;
                    return;
                }
                if (ClsUserAccountsServices.EmailAlreadyExists)
                {
                    // EmailAlreadyExistsMsg
                    lblMsgBox.Text      = ClsAppMsgs.EmailAlreadyExistsMsg;
                    lblMsgBox.BackColor = ColorTranslator.FromHtml("#fff5cc");
                    lblMsgBox.ForeColor = ColorTranslator.FromHtml("#856404");
                    lblMsgBox.Visible   = true;
                    TxtBoxUserEmail.Focus();
                    await Task.Delay(3000);

                    lblMsgBox.Visible = false;
                    ClsUserAccountsServices.EmailAlreadyExists = false;
                    return;
                }
                IsClearing = true;
                TxtBoxScreenUserName.Text     = TxtBoxUserEmail.Text = CombBoxUserRole.Text = TxtBoxPassword.Text = TxtBoxPasswordConfirm.Text = "";
                CombBoxUserRole.SelectedItem  = null;
                CombBoxUserRole.SelectedIndex = -1;
                CombBoxUserRole.Refresh();
                lblMsgBox.Text      = ClsAppMsgs.RegisteredDataMsg;
                lblMsgBox.BackColor = ColorTranslator.FromHtml("#deffef");
                lblMsgBox.ForeColor = ColorTranslator.FromHtml("#009e52");
                lblMsgBox.Visible   = true;
                await Task.Delay(5000);

                lblMsgBox.Visible = false;
                ImgBtnBack.Focus();
            }
            catch
            {
                lblMsgBox.Text      = ClsAppMsgs.RegistrationErrorOccurredMsg;
                lblMsgBox.BackColor = ColorTranslator.FromHtml("#ffedf6");
                lblMsgBox.ForeColor = ColorTranslator.FromHtml("#d20051");
                lblMsgBox.Visible   = true;
                TxtBoxUserEmail.Focus();
                await Task.Delay(3000);

                lblMsgBox.Visible = false;
            }
        }