Example #1
0
        private void CheckPassword()
        {
            try
            {
                string StrCriteria = " U_CODE='" + txtUserId.Text.Trim() + "' AND U_NAME='" + txtUserName.Text.Trim() + "'";

                if (GLOBAL.UserGroup.ToUpper() != "ADMIN")
                {
                    DataRow[] row = GLOBAL.ds.Tables["USER_MAS"].Select(StrCriteria);
                    if (row.Length != 0)
                    {
                        string Password = Convert.ToString(row[0]["PASS"]);
                        string DcodePass;
                        DcodePass = GLOBAL.ECODE_DECODE(Password.ToUpper(), "D");
                        if (txtOldPassword.Text.Trim().ToUpper() == DcodePass.ToUpper())
                        {
                            return;
                        }
                        else
                        {
                            MessageBox.Show("Incorrect Password.Please retype it", "Invalid", MessageBoxButtons.OK);
                            txtOldPassword.Text = "";
                            txtOldPassword.Focus();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        private void CheckLogin()
        {
            try
            {
                string StrCriteria = "";
                if (txtUserId.Text.Trim().Length > 0 && txtPassword.Text.Trim().Length > 0)
                {
                    StrCriteria = " U_CODE='" + txtUserId.Text.Trim() + "' AND U_NAME='" + txtUserName.Text.Trim() + "'";
                }
                else if (txtUserName.Text.Trim().Length > 0)
                {
                    StrCriteria = " U_NAME='" + txtUserName.Text.Trim() + "'";
                }
                else if (txtUserId.Text.Trim().Length > 0)
                {
                    StrCriteria = " U_CODE='" + txtUserId.Text.Trim() + "'";
                }

                string    EncodePwd;
                DataRow[] row = GLOBAL.ds.Tables["USER_MAS"].Select(StrCriteria);
                if (row.Length == 0)
                {
                    EncodePwd = GLOBAL.ECODE_DECODE(("Admin").Trim(), "E");
                    GLOBAL.ds.Tables["USER_MAS"].Rows.Add("A", "Admin", EncodePwd, "Admin");
                    MessageBox.Show("New User Created successfully", "User Created", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    //try
                    //{
                    //    GLOBAL.ds.WriteXmlSchema(Application.StartupPath + @"\QUICK_LAB.xsd");
                    //    GLOBAL.ds.WriteXml(Application.StartupPath + @"\QUICK_LAB.xml");
                    //    MessageBox.Show("Record save successfully!", "S");
                    //    this.Close();
                    //}
                    //catch (Exception ex)
                    //{
                    //    MessageBox.Show("Error :" + ex.Message);
                    //}
                    MdiMain main = new MdiMain();
                    main.ShowDialog();
                    this.Close();
                }

                string User     = "";
                string Password = "";
                if (InputData())
                {
                    if (row.Length != 0)
                    {
                        User     = Convert.ToString(row[0]["U_CODE"]);
                        Password = Convert.ToString(row[0]["PASS"]);
                    }

                    if (txtUserId.Text.Trim().ToUpper() == User.ToUpper())
                    {
                        string DcodePass;
                        DcodePass = GLOBAL.ECODE_DECODE(Password.ToUpper(), "D");
                        if (txtPassword.Text.Trim().ToUpper() == DcodePass.ToUpper())
                        {
                            GLOBAL.loginUserId   = txtUserId.Text.Trim().ToUpper();
                            GLOBAL.loginUserName = txtPassword.Text.Trim().ToUpper();
                            GLOBAL.UserGroup     = Convert.ToString(row[0]["U_GROUP"]);
                            MdiMain main = new MdiMain();
                            //this.Close();
                            main.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Incorrect Password.Please retype it", "Invalid", MessageBoxButtons.OK);
                            txtPassword.Text = "";
                            txtPassword.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Incorrect UserId / UserName.Please retype it", "Invalid", MessageBoxButtons.OK);
                        txtUserId.Text   = "";
                        txtUserName.Text = "";
                        txtPassword.Text = "";
                        txtUserId.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }