public int UpdateUserAssignRight(UserAssignRightEntity oUserAssignRightEntity) { con = oConnectionDatabase.DatabaseConnection(); try { con.Open(); } catch { } int i = 0; //cmd = new SqlCommand("INSERT INTO tblCustomerImage (CustomerID,CustomerImage,CustomerSignature,Creatby,LastModifiedBy) VALUES('" + customerId + "','" + image + "','" + signature + "','" + Creatby + "','" + LastModifiedBy + "')", con); cmd = new SqlCommand("UPDATE tblUserAssignRights SET MenuRights=@MenuRights,SubMenuRights=@SubMenuRights,LastModifiedBy=@LastModifiedBy WHERE UserID=@UserID and MenuNo=@MenuNo and SubMenuNo=@SubMenuNo", con); //cmd = new SqlCommand("INSERT INTO tblUserInfo (UserID,UserType,Password,ConfirmPassword,Active,LastModifiedBy) VALUES(@UserID,@UserType,@Password,@ConfirmPassword,@Active,@LastModifiedBy)", con); cmd.Parameters.AddWithValue("@UserID", SqlDbType.VarChar).Value = oUserAssignRightEntity.UserID; cmd.Parameters.AddWithValue("@MenuNo", SqlDbType.Image).Value = oUserAssignRightEntity.MenuNo; cmd.Parameters.AddWithValue("@SubMenuNo", SqlDbType.VarChar).Value = oUserAssignRightEntity.SubMenuNo; cmd.Parameters.AddWithValue("@MenuRights", SqlDbType.Image).Value = oUserAssignRightEntity.MenuRights; cmd.Parameters.AddWithValue("@SubMenuRights", SqlDbType.VarChar).Value = oUserAssignRightEntity.SubMenuRights; cmd.Parameters.AddWithValue("@LastModifiedBy", SqlDbType.VarChar).Value = oUserAssignRightEntity.LastModifiedBy; try { cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); i = 1; } catch { } con.Close(); return(i); }
public int InsertUserAssignRight(UserAssignRightEntity oUserAssignRightEntity) { con = oConnectionDatabase.DatabaseConnection(); try { con.Open(); } catch { } int i = 0; //cmd = new SqlCommand("INSERT INTO tblCustomerImage (CustomerID,CustomerImage,CustomerSignature,Creatby,LastModifiedBy) VALUES('" + customerId + "','" + image + "','" + signature + "','" + Creatby + "','" + LastModifiedBy + "')", con); cmd = new SqlCommand("INSERT INTO tblUserAssignRights (UserID,MenuNo,MenuRights,SubMenuNo,SubMenuRights,CreateBy,LastModifiedBy) VALUES(@UserID,@MenuNo,@MenuRights,@SubMenuNo,@SubMenuRights,@CreateBy,@LastModifiedBy)", con); cmd.Parameters.AddWithValue("@UserID", SqlDbType.VarChar).Value = oUserAssignRightEntity.UserID; cmd.Parameters.AddWithValue("@MenuNo", SqlDbType.Image).Value = oUserAssignRightEntity.MenuNo; cmd.Parameters.AddWithValue("@SubMenuNo", SqlDbType.VarChar).Value = oUserAssignRightEntity.SubMenuNo; cmd.Parameters.AddWithValue("@MenuRights", SqlDbType.Image).Value = oUserAssignRightEntity.MenuRights; cmd.Parameters.AddWithValue("@SubMenuRights", SqlDbType.VarChar).Value = oUserAssignRightEntity.SubMenuRights; cmd.Parameters.AddWithValue("@CreateBy", SqlDbType.Image).Value = oUserAssignRightEntity.CreateBy; cmd.Parameters.AddWithValue("@LastModifiedBy", SqlDbType.VarChar).Value = oUserAssignRightEntity.LastModifiedBy; try { cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); i = 1; } catch { } con.Close(); return(i); }
public int DeleteUserAssignRight(UserAssignRightEntity oUserAssignRightEntity) { con = oConnectionDatabase.DatabaseConnection(); int i = 0; cmd = new SqlCommand("DELETE FROM tblUserAssignRights WHERE ID=" + oUserAssignRightEntity.ID, con); try { cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); i = 1; } catch { } con.Close(); return(i); }
protected void assignRightButton_Click(object sender, EventArgs e) { if (userDropDownList.SelectedValue == "" || userDropDownList.SelectedValue == null) { return; } if (menuItemDropDownList.SelectedValue == "" || menuItemDropDownList.SelectedValue == null) { return; } for (int k = 0; k < GridView1.Rows.Count; k++) { UserAssignRightEntity oUserAssignRightEntity = new UserAssignRightEntity(); oUserAssignRightEntity.UserID = userDropDownList.SelectedValue; oUserAssignRightEntity.MenuNo = menuItemDropDownList.SelectedValue; oUserAssignRightEntity.SubMenuNo = ((Label)GridView1.Rows[k].FindControl("SubMenuNoLabel")).Text; oUserAssignRightEntity.MenuRights = true; if (allCheckBox.Checked == true) { oUserAssignRightEntity.SubMenuRights = true; } else { if (((CheckBox)GridView1.Rows[k].FindControl("CheckBox1")).Checked) { oUserAssignRightEntity.SubMenuRights = true; } else { oUserAssignRightEntity.SubMenuRights = false; } } oUserAssignRightEntity.CreateBy = DateTime.Now.ToShortDateString(); oUserAssignRightEntity.LastModifiedBy = DateTime.Now.ToShortDateString(); int n = oUserAssignRightDAO.UpdateUserAssignRight(oUserAssignRightEntity); } gridViewBind(); }
protected void saveButton_Click(object sender, EventArgs e) { if (userNameDropDownList.SelectedValue == "" || userNameDropDownList.SelectedValue == null) { return; } oUserInfoEntity.UserID = userIdTextBox.Text; oUserInfoEntity.UserType = userTypeDropDownList.SelectedValue; oUserInfoEntity.Password = passwordTextBox.Text; oUserInfoEntity.ConfirmPassword = confirmPasswordTextBox.Text; oUserInfoEntity.Active = activeCheckBox.Checked; oUserInfoEntity.EmployeeID = userNameDropDownList.SelectedValue; oUserInfoEntity.CreateBy = DateTime.Now.ToShortDateString(); oUserInfoEntity.LastModifiedBy = DateTime.Now.ToShortDateString(); string message = ""; if (oUserInfoEntity.Password != oUserInfoEntity.ConfirmPassword) { message = "Password and confirmed password are not same"; ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "MessageBox", "alert('" + message + "')", true); return; } if (saveButton.Text == "Update") { if (Session["ID"] != null) { oUserInfoEntity.ID = Convert.ToInt16(Session["ID"]); int i = oUserInfoDAO.UpdateUserInfo(oUserInfoEntity); if (i == 1) { message = "User Updated Successfully"; Clear(); } else { message = "User Not Updated!"; } } } else { string condition = " where userId='" + oUserInfoEntity.UserID + "'"; DataTable dt = oUserInfoDAO.GetUserInfo(condition); if (dt.Rows.Count > 0) { message = "User Id already in Database"; ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "MessageBox", "alert('" + message + "')", true); return; } int i = oUserInfoDAO.InsertUserInfo(oUserInfoEntity); if (i == 1) { MenuAndSubMenuDAO oMenuAndSubMenuDAO = new MenuAndSubMenuDAO(); dt = oMenuAndSubMenuDAO.GetSubMenu(""); UserAssignRightDAO oUserAssignRightDAO = new UserAssignRightDAO(); for (int k = 0; k < dt.Rows.Count; k++) { UserAssignRightEntity oUserAssignRightEntity = new UserAssignRightEntity(); oUserAssignRightEntity.UserID = oUserInfoEntity.UserID; oUserAssignRightEntity.MenuNo = dt.Rows[k]["MenuNo"].ToString(); oUserAssignRightEntity.SubMenuNo = dt.Rows[k]["SubMenuNo"].ToString(); oUserAssignRightEntity.MenuRights = false; oUserAssignRightEntity.SubMenuRights = false; oUserAssignRightEntity.CreateBy = DateTime.Now.ToShortDateString(); oUserAssignRightEntity.LastModifiedBy = DateTime.Now.ToShortDateString(); int n = oUserAssignRightDAO.InsertUserAssignRight(oUserAssignRightEntity); } message = "User Created Successfully"; Clear(); } else { message = "User Not Created!"; } } gridViewBind(); ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "MessageBox", "alert('" + message + "')", true); }