private void buttonOk_Click(object sender, EventArgs e) { if (!superValidator1.Validate()) return; try { if (UserAction == "edit") { Function.FucntionName = textBoxFunctionName.Text; Function.Button = textBoxButton.Text; DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin chức năng này không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { if (RoleFunction.UpdateFunction(Function) > 0) MessageBox.Show("Cập nhập chức năng thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { RoleFunction newFunction = new RoleFunction(0, textBoxFunctionName.Text, textBoxButton.Text); if (RoleFunction.InsertFunction(newFunction) > 0) MessageBox.Show("Thêm chức năng thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); }
public void SetRoleDetail(Role roledetail) { this.roleDetail = roledetail; textBoxRoleID.Text = roleDetail.RoleID.ToString(); textBoxRoleName.Text = roleDetail.RoleName; DataTable dtCurrentFunction = RoleDetail.GetListStaffFunction(roledetail.RoleID); for (int i = 0; i < dtCurrentFunction.Rows.Count; i++) { RoleFunction tempRF=new RoleFunction(int.Parse(dtCurrentFunction.Rows[i][0].ToString()),dtCurrentFunction.Rows[i][1].ToString(),""); listBoxCurrentFunction.Items.Add(tempRF.FucntionName); listBoxCurrentFunctionID.Items.Add(tempRF.FunctionID); } DataTable dtSystemFunction = RoleFunction.GetListFunction(); for (int i = 0; i < dtSystemFunction.Rows.Count; i++) { RoleFunction tempRF = new RoleFunction(int.Parse(dtSystemFunction.Rows[i][0].ToString()), dtSystemFunction.Rows[i][1].ToString(), dtSystemFunction.Rows[i][2].ToString()); listBoxSystemFunction.Items.Add(tempRF.FucntionName); listBoxSystemFunctionID.Items.Add(tempRF.FunctionID); } ListBox lstTemp = new ListBox(); for (int i = 0; i < listBoxCurrentFunctionID.Items.Count; i++) { for (int j = 0; j < listBoxSystemFunctionID.Items.Count; j++) { if (listBoxCurrentFunctionID.Items[i].ToString() == listBoxSystemFunctionID.Items[j].ToString()) { listBoxSystemFunctionID.Items.RemoveAt(j); listBoxSystemFunction.Items.RemoveAt(j); break; } } } }
public FormRoleFunctionDetail(RoleFunction function, String usertAction) { InitializeComponent(); this.Function = function; this.UserAction = usertAction; if(UserAction == "edit") SetRoleFunctionDetail(function); }
public static int InsertFunction(RoleFunction newFunction) { String sqlInsert = @"INSERT INTO ROLEFUNCTION(FUNCTIONNAME, BUTTON) VALUES (@FUNCTIONNAME,@BUTTON)"; SqlParameter[] sqlParameters = { new SqlParameter("@FUNCTIONNAME", newFunction.FucntionName), new SqlParameter("@BUTTON", newFunction.Button)}; return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters); }
public static int InsertFunction(RoleFunction newFunction) { String sqlInsert = @"INSERT INTO ROLEFUNCTION(FUNCTIONNAME, BUTTON) VALUES (@FUNCTIONNAME,@BUTTON)"; SqlParameter[] sqlParameters = { new SqlParameter("@FUNCTIONNAME", newFunction.FucntionName), new SqlParameter("@BUTTON", newFunction.Button) }; return(SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters)); }
public static int UpdateFunction(RoleFunction updateFunction) { string sqlUpdate = @"UPDATE ROLEFUNCTION SET FUNCTIONNAME =@FUNCTIONNAME, BUTTON =@BUTTON WHERE FUNCTIONID=@FUNCTIONID "; SqlParameter[] sqlParameters = { new SqlParameter("@FUNCTIONID", updateFunction.FunctionID), new SqlParameter("@FUNCTIONNAME", updateFunction.FucntionName), new SqlParameter("@BUTTON", updateFunction.Button)}; return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters); }
public static int UpdateFunction(RoleFunction updateFunction) { string sqlUpdate = @"UPDATE ROLEFUNCTION SET FUNCTIONNAME =@FUNCTIONNAME, BUTTON =@BUTTON WHERE FUNCTIONID=@FUNCTIONID "; SqlParameter[] sqlParameters = { new SqlParameter("@FUNCTIONID", updateFunction.FunctionID), new SqlParameter("@FUNCTIONNAME", updateFunction.FucntionName), new SqlParameter("@BUTTON", updateFunction.Button) }; return(SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters)); }
public FormRoleDetail() { InitializeComponent(); DataTable dtSystemFunction = RoleFunction.GetListFunction(); for (int i = 0; i < dtSystemFunction.Rows.Count; i++) { RoleFunction tempRF = new RoleFunction(int.Parse(dtSystemFunction.Rows[i][0].ToString()), dtSystemFunction.Rows[i][1].ToString(), dtSystemFunction.Rows[i][2].ToString()); listBoxSystemFunction.Items.Add(tempRF.FucntionName); listBoxSystemFunctionID.Items.Add(tempRF.FunctionID); } }
public static RoleFunction GetFunction(int functionID) { RoleFunction newFunction = new RoleFunction(); int tempInterger; string sqlSelect = @"SELECT FUNCTIONID, FUNCTIONNAME, BUTTON FROM ROLEFUNCTION WHERE FUNCTIONID=@FUNCTIONID"; SqlParameter[] sqlParameters = { new SqlParameter("@FUNCTIONID", functionID) }; DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters); if (dataTable.Rows.Count > 0) { int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger); newFunction.FunctionID = tempInterger; newFunction.FucntionName = dataTable.Rows[0][1].ToString(); newFunction.Button = dataTable.Rows[0][2].ToString(); } return newFunction; }
public static RoleFunction GetFunction(int functionID) { RoleFunction newFunction = new RoleFunction(); int tempInterger; string sqlSelect = @"SELECT FUNCTIONID, FUNCTIONNAME, BUTTON FROM ROLEFUNCTION WHERE FUNCTIONID=@FUNCTIONID"; SqlParameter[] sqlParameters = { new SqlParameter("@FUNCTIONID", functionID) }; DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters); if (dataTable.Rows.Count > 0) { int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger); newFunction.FunctionID = tempInterger; newFunction.FucntionName = dataTable.Rows[0][1].ToString(); newFunction.Button = dataTable.Rows[0][2].ToString(); } return(newFunction); }
private void SetRoleFunctionDetail(RoleFunction function) { textBoxFunctionID.Text = function.FunctionID.ToString(); textBoxFunctionName.Text = function.FucntionName; textBoxButton.Text = function.Button; }