private void Btn_ok_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.None; switch (_type) { case "FINANCE": if (Program.System_user.Has_permission(Class_enum.User_permission.ADD_EDIT_FINANCE)) { Finance_ds.Update_insert_finance(_orgbranch_id, txt_remark.Text.Trim()); } break; case "INSURANCE": if (Program.System_user.Has_permission(Class_enum.User_permission.INSURANCE_ADD_EDIT)) { Insurance_ds.Update_insert_insurance(_orgbranch_id, txt_remark.Text.Trim()); } break; case "LOAN": if (Program.System_user.Has_permission(Class_enum.User_permission.LOAN_ADD_EDIT)) { Loan_ds.Update_insert_loan(_orgbranch_id, txt_remark.Text.Trim()); } break; } this.DialogResult = DialogResult.OK; this.Close(); }
public Form_edit_finance(int int_orgbranch_id, string str_type) { InitializeComponent(); _orgbranch_id = int_orgbranch_id; _type = str_type.ToUpper(); switch (_type) { case "FINANCE": using (Finance_ds.sp_select_financeDataTable dttable = Finance_ds.Select_finance(_orgbranch_id)) { if (dttable.Rows.Count > 0) { txt_remark.Text = dttable[0].remark; } } break; case "INSURANCE": using (Insurance_ds.sp_select_insuranceDataTable dttable = Insurance_ds.Select_insurance(_orgbranch_id)) { if (dttable.Rows.Count > 0) { txt_remark.Text = dttable[0].remark; } } break; case "LOAN": using (Loan_ds.sp_select_loanDataTable dttable = Loan_ds.Select_loan(_orgbranch_id)) { if (dttable.Rows.Count > 0) { txt_remark.Text = dttable[0].remark; } } break; } }
private void Form_edit_finance_Shown(object sender, EventArgs e) { bool has_permission = true; switch (_type.ToUpper()) { case "FINANCE": has_permission = Program.System_user.Has_permission(Class_enum.User_permission.VIEW_FINANCE) || Program.System_user.Has_permission(Class_enum.User_permission.ADD_EDIT_FINANCE); using (Finance_ds.sp_select_financeDataTable dttable = Finance_ds.Select_finance(_orgbranch_id)) { if (dttable.Rows.Count > 0) { txt_remark.Text = dttable[0].remark; } } if (!Program.System_user.Has_permission(Class_enum.User_permission.ADD_EDIT_FINANCE)) { // no permission to add/edit finance btn_ok.Visible = false; txt_remark.ReadOnly = true; } break; case "INSURANCE": using (Insurance_ds.sp_select_insuranceDataTable dttable = Insurance_ds.Select_insurance(_orgbranch_id)) { if (dttable.Rows.Count > 0) { txt_remark.Text = dttable[0].remark; } } if (!Program.System_user.Has_permission(Class_enum.User_permission.INSURANCE_ADD_EDIT)) { btn_ok.Visible = false; txt_remark.ReadOnly = true; has_permission = false; } break; case "LOAN": using (Loan_ds.sp_select_loanDataTable dttable = Loan_ds.Select_loan(_orgbranch_id)) { if (dttable.Rows.Count > 0) { txt_remark.Text = dttable[0].remark; } } if (!Program.System_user.Has_permission(Class_enum.User_permission.LOAN_ADD_EDIT)) { btn_ok.Visible = false; txt_remark.ReadOnly = true; has_permission = false; } break; default: has_permission = false; break; } if (!has_permission) { MessageBox.Show("You do not have sufficient permission to perform this action!", "ACCESS DENIED", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Setup_form(); }