public PostLoginModel getLoginByLoginID(int LoginID) { PostLoginModel model = new PostLoginModel(); string query = "select * from login where LoginID = @LoginID"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@LoginID", LoginID), }; using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand(query, CommandType.Text, parameters)) { if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; model.ClientID = Convert.ToInt32(row["ClientID"]); model.RoleID = Convert.ToInt32(row["RoleID"]); model.User = row["User"].ToString(); model.Comment = row["Comment"].ToString(); model.Password = row["Password"].ToString(); model.DisplayName = row["DisplayName"].ToString(); } } return(model); }
public bool postLogin(PostLoginModel _object) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@LoginID", _object.LoginID), new SqlParameter("@ClientID", _object.ClientID), new SqlParameter("@RoleID", _object.RoleID), new SqlParameter("@User", _object.User), new SqlParameter("@Password", _object.Password), new SqlParameter("@Comment", _object.Comment), new SqlParameter("@DisplayName", _object.DisplayName), }; return(DBHelper.ExecuteNonQuery("uspPOST_Login", CommandType.StoredProcedure, parameters)); }
protected void linkbtnEdit_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "UpdateID") { allowStaticMethods("applyDatatable('.gvduserclass');staticMethod('Enable');"); int ID = Convert.ToInt32(e.CommandArgument); PostLoginModel li = obj.getLoginByLoginID(ID); txtUser.Text = li.User; txtPassword.Attributes.Add("value", li.Password); txtConfirmPassword.Attributes.Add("value", li.Password); txtComments.Text = li.Comment; txtdisplayName.Text = li.DisplayName; ddlUserType.SelectedValue = li.RoleID.ToString(); ddlClient.SelectedValue = li.ClientID.ToString(); Session["loginId"] = ID.ToString(); btnAddUser.Text = "Update"; txtUser.Enabled = false; } } catch (Exception) { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); } }
public bool postLogin(PostLoginModel _object) { return(obj.postLogin(_object)); }
//Button clicks protected void btnAddUser_Click(object sender, EventArgs e) { try { if (ddlClient.SelectedValue != "0" && txtUser.Text != "" && txtPassword.Text != "" && txtConfirmPassword.Text != "") { PostLoginModel model = new PostLoginModel(); model.ClientID = Convert.ToInt32(ddlClient.SelectedValue); model.RoleID = Convert.ToInt32(ddlUserType.SelectedValue); model.User = txtUser.Text; model.Password = txtPassword.Text; model.Comment = txtComments.Text; model.DisplayName = txtdisplayName.Text; if (txtPassword.Text == txtConfirmPassword.Text) { if (btnAddUser.Text == "Save") { model.LoginID = 0; bool exist = obj.usernameExist(model.User); if (exist == false) { bool status = obj.postLogin(model); if (status == true) { alert = AlertsClass.SuccessAdd; } else { alert = AlertsClass.ErrorPasswordMatch; } } else { alert = AlertsClass.ErrorExist("Username"); } } if (btnAddUser.Text == "Update") { model.LoginID = Convert.ToInt32(Session["LoginId"]); bool status = obj.postLogin(model); if (status == true) { alert = AlertsClass.SuccessUpdate; } } } else { alert = AlertsClass.ErrorPasswordMatch; } clearControls(); gridBind(Convert.ToInt32(ddlClient.SelectedValue)); allowStaticMethods(" ALerts('" + alert + "'); applyDatatable('.gvduserclass'); staticMethod('Disable');"); } else { alert = AlertsClass.ErrorRequired; } } catch (Exception) { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); } }