private void changeUserPassword() { try { string encodePass = GLOBAL.ECODE_DECODE((txtNewPassword.Text).Trim(), "E"); if (txtNewPassword.Text != "" && txtConfirmPassword.Text != "" && (txtNewPassword.Text.Trim() == txtConfirmPassword.Text.Trim())) { string StrCriteria = " U_CODE='" + txtUserId.Text.Trim() + "'"; DataRow[] row = GLOBAL.ds.Tables["USER_MAS"].Select(StrCriteria); if (RequiredField()) { if (row.Length != 0) { int rowIndex = GLOBAL.ds.Tables["USER_MAS"].Rows.IndexOf(row[0]); GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["U_CODE"] = txtUserId.Text; GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["U_NAME"] = txtUserName.Text; GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["PASS"] = encodePass; GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["U_GROUP"] = cboUserGroup.Text; MessageBox.Show("User Password updated", "Data Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
private void SaveNewUSer() { try { string encodePass = GLOBAL.ECODE_DECODE((txtNewPassword.Text).Trim(), "E"); string StrCriteria = " U_CODE='" + txtUserId.Text.Trim() + "' AND U_NAME='" + txtUserName.Text.Trim() + "'"; DataRow[] row = GLOBAL.ds.Tables["USER_MAS"].Select(StrCriteria); if (RequiredField()) { if (row.Length != 0) { int rowIndex = GLOBAL.ds.Tables["USER_MAS"].Rows.IndexOf(row[0]); GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["U_CODE"] = txtUserId.Text; GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["U_NAME"] = txtUserName.Text; GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["PASS"] = encodePass; GLOBAL.ds.Tables["USER_MAS"].Rows[rowIndex]["U_GROUP"] = cboUserGroup.Text; MessageBox.Show("User Password updated", "Data Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { GLOBAL.ds.Tables["USER_MAS"].Rows.Add(txtUserId.Text, txtUserName.Text, encodePass, cboUserGroup.Text); MessageBox.Show("New User Sucessfully Inserted", "Data Inserted", MessageBoxButtons.OK, MessageBoxIcon.Information); } } btn_NewUser.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }