protected void btnSave_Click(object sender, EventArgs e) { if (txtNewPwd.Text == "") { txtNewPwd.Focus(); return; } if (txtConfirmPwd.Text == txtNewPwd.Text) { BL_Users obj = new BL_Users(); obj.USER_NAME = ""; obj.ID = Convert.ToInt32(Session["UserId"]); obj.REGISTERED_DATE = System.DateTime.Now; obj.PWD = EncryptDecrypt.base64Encode(txtConfirmPwd.Text); obj.EVENT = 'C'; int Id = 0; string msg = ""; msg = obj.InsUpdDeleteUsers(out Id); if (msg == "Password Changed Successfully") { msgbox.ShowSuccess(msg); txtNewPwd.Text = ""; txtConfirmPwd.Text = ""; txtCurrentPwd.Text = ""; } else { msgbox.ShowWarning(msg); } } }
private void InsupdDeleteusers(char Event, int Id) { var obj = new BL_Users(); if (Event == 'I') { if (txtPassword.Text == txtConfirmPassword.Text) { obj.EVENT = 'I'; // obj.NAME = txtFirstName.Text + " " + txtLastName.Text; obj.STAFF_ID = Convert.ToInt32((string)ddlStaffName.SelectedValue); obj.PWD = EncryptDecrypt.base64Encode(txtPassword.Text); obj.CONTACT_NO = txtContactNo.Text; obj.ADDRESS = txtAddress.Text; obj.EMAIL_ID = txtEmail.Text; obj.REGISTERED_BY = Convert.ToInt32(BK_Session.GetSession().UserId); obj.REGISTERED_DATE = System.DateTime.Now; obj.USER_NAME = txtUserName.Text + lblCompanyCode.Text; obj.USER_STATUS = true; obj.ROLE_ID = Convert.ToInt32((string)ddlRoles.SelectedValue); obj.BranchId = Convert.ToInt32(BK_Session.GetSession().BranchId); Id = 0; var msg = ""; msg = obj.InsUpdDeleteUsers(out Id); if (msg == "Record Inserted Successfully") { msgbox.ShowSuccess(msg); Clear(); } else { msgbox.ShowWarning(msg); } } } else if (Event == 'U') { obj.EVENT = Event; obj.ID = Id; obj.STAFF_ID = Convert.ToInt32((string)ddlStaffName.SelectedValue); obj.PWD = EncryptDecrypt.base64Encode(txtPassword.Text + lblCompanyCode.Text); obj.CONTACT_NO = txtContactNo.Text; obj.ADDRESS = txtAddress.Text; obj.EMAIL_ID = txtEmail.Text; obj.REGISTERED_BY = Convert.ToInt32(BK_Session.GetSession().UserId); obj.REGISTERED_DATE = BK_Session.GetSession().OpDate; obj.USER_NAME = txtUserName.Text; obj.USER_STATUS = true; obj.ROLE_ID = Convert.ToInt32((string)ddlRoles.SelectedValue); obj.BranchId = Convert.ToInt32(BK_Session.GetSession().BranchId); Id = 0; var msg = ""; msg = obj.InsUpdDeleteUsers(out Id); if (msg == "Record Updated Successfully") { msgbox.ShowSuccess(msg); Clear(); } else { msgbox.ShowWarning(msg); } } else if (Event == 'D') { obj.EVENT = Event; obj.ID = Id; obj.STAFF_ID = Convert.ToInt32((string)ddlStaffName.SelectedValue); obj.PWD = EncryptDecrypt.base64Encode(txtPassword.Text); obj.ADDRESS = txtAddress.Text; obj.CONTACT_NO = txtContactNo.Text; obj.EMAIL_ID = txtEmail.Text; obj.REGISTERED_BY = Convert.ToInt32(BK_Session.GetSession().UserId); obj.REGISTERED_DATE = BK_Session.GetSession().OpDate; obj.USER_NAME = txtUserName.Text; Id = 0; var msg = ""; msg = obj.InsUpdDeleteUsers(out Id); if (msg == "Record Deleted Successfully") { msgbox.ShowSuccess(msg); Clear(); } else { msgbox.ShowWarning(msg); } } else { obj.EVENT = Event; obj.ID = Id; obj.STAFF_ID = Convert.ToInt32((string)ddlStaffName.SelectedValue); var pwd = (txtPassword.Text).ToLower(); obj.PWD = EncryptDecrypt.base64Encode(pwd); obj.ADDRESS = txtAddress.Text; obj.CONTACT_NO = txtContactNo.Text; obj.EMAIL_ID = txtEmail.Text; obj.REGISTERED_BY = Convert.ToInt32(BK_Session.GetSession().UserId); obj.REGISTERED_DATE = BK_Session.GetSession().OpDate; obj.USER_NAME = txtUserName.Text; Id = 0; var msg = ""; msg = obj.InsUpdDeleteUsers(out Id); if (msg == "Password Changed Successfully") { msgbox.ShowSuccess(msg); Clear(); } else { msgbox.ShowWarning(msg); } } FillgvUsers(); }