예제 #1
0
        private void btnsubmit_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            UserMasterSaver userMasterSaver = new UserMasterSaver();
            LogSaver logsaver = new LogSaver();

            statusStrip.Text = "Authenticating..";
            Cursor.Current = Cursors.WaitCursor;

            #region compare txt and db values
            if (string.IsNullOrEmpty(txtusernm.Text) || string.IsNullOrEmpty(txtpasswd.Text))
            {
                MessageBox.Show("Username and Password are Mandatory." + Environment.NewLine + "Please try again.", "Incorrect Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                statusStrip.Text = "Waiting for User's input...";
                return;
            }
            else
            {
                userId = userMasterSaver.fetchUSPID(txtusernm.Text, txtpasswd.Text);
                if (userId == null)
                {
                    MessageBox.Show("Username / Password is Incorrect." + Environment.NewLine + "Please try again.", "Incorrect Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    statusStrip.Text = "Waiting for User's input...";
                    disableMenu();
                    return;
                }
                //on match continue..
                User.UserId = (int)userId;
            }
            #endregion compare txt and db values

            logsaver.insert((int)userId, DateTime.Now.Date.ToString("yyyy-MM-dd"), DateTime.Now.ToShortTimeString());
            dt = userMasterSaver.FetchUserAttribute(userId);
            enableMenu(dt);
            Cursor.Current = Cursors.Default;
        }
예제 #2
0
        protected override void btnsave_Click(object sender, EventArgs e)
        {
            UserMasterSaver userMasterSaver = new UserMasterSaver();
            int USPUserid;

            if (string.IsNullOrEmpty(txtUsrname.Text) || string.IsNullOrEmpty(txtPass.Text) || string.IsNullOrEmpty(txtConPass.Text))
            {
                MessageBox.Show("Username and Password are Mandatory." + Environment.NewLine + "Please try again.", "Incorrect Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            #region check if pass and con pass match
            if (string.Compare(txtConPass.Text, txtPass.Text) != 0)
            {
                MessageBox.Show("Password and Confirm Password do not match." + Environment.NewLine + "Please try again.", "Incorrect Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPass.Text = string.Empty;
                txtUsrname.Focus();
                txtUsrname.Text = string.Empty;
                txtConPass.Text = string.Empty;
                return;
            }
            #endregion check if pass and con pass match

            #region InsertUserPrivileges
            if (UpdateState != true)
            {
                try
                {

                    userMasterSaver.insertUserPrivileges(txtUsrname.Text, txtPass.Text);
                    USPUserid = userMasterSaver.fetchEmpID(txtUsrname.Text);
                    for (int i = 0; i < this.chklstbx.Items.Count; i++)
                    {
                        userMasterSaver.insertUserAttribute(USPUserid, i, Convert.ToInt16(this.chklstbx.GetItemChecked(i)));
                    }
                }
                catch (Exception ex)
                {
                    ErrorDump ed = new ErrorDump();
                    ed.WriteToErrorLog(ErrorDump.ErrorDumpErrorLogType.Information, ex, "Saving UserMaster Failed. Please try again");
                }
            }
            #endregion InsertUserPrivileges
            else
            #region updateUserPrivilege
            {
                USPUserid = userMasterSaver.fetchEmpID(txtUsrname.Text);
                userMasterSaver.updateUserPrivilege(USPUserid);
                for (int i = 0; i < this.chklstbx.Items.Count; i++)
                {
                    userMasterSaver.updateUserAttribute(USPUserid, Convert.ToInt16(this.chklstbx.GetItemChecked(i)), i);
                    MysqlConn.executeQry(qry);
                }
                txtPass.Enabled = true;
                txtConPass.Enabled = true;
                UpdateState = false;
            }
            #endregion updateUserPrivilege

            updateStatus(this, "Values Saved");

            com.clearAllControl(GrbxNewUser, false);
            LoadUserPrivileges_CheckBox("");
            txtUsrname.Focus();
        }