protected void btnSave_Click(object sender, EventArgs e) { try { bool ret = true; List <UserRoleMatrixData> dataInsert = new List <UserRoleMatrixData>(); if (gvResult.Rows.Count > 0) { for (int i = 0; i < gvResult.Rows.Count; i++) { RadioButton rdHavePrivilege = (RadioButton)gvResult.Rows[i].FindControl("rdHavePrivilege"); RadioButton rdNoPrivilege = (RadioButton)gvResult.Rows[i].FindControl("rdNoPrivilege"); Label lblValidateId = (Label)gvResult.Rows[i].FindControl("lblValidateId"); Label lblScreenId = (Label)gvResult.Rows[i].FindControl("lblScreenId"); Label lblStaffTypeId = (Label)gvResult.Rows[i].FindControl("lblStaffTypeId"); if (rdHavePrivilege != null && rdNoPrivilege != null) { if (rdHavePrivilege.Checked == true || rdNoPrivilege.Checked == true)//กรณีมีการ check มีสิทธิหรือไม่มีสิทธิ { UserRoleMatrixData udata = new UserRoleMatrixData(); if (lblValidateId != null && !string.IsNullOrEmpty(lblValidateId.Text.Trim())) { udata.ValidateId = lblValidateId.Text.Trim(); } if (lblStaffTypeId != null && !string.IsNullOrEmpty(lblStaffTypeId.Text.Trim())) { udata.StaffTypeId = lblStaffTypeId.Text.Trim(); } if (rdHavePrivilege.Checked == true) { udata.isView = "1"; } else if (rdNoPrivilege.Checked == true) { udata.isView = "0"; } udata.ScreenId = txtScreen.Text; dataInsert.Add(udata); } } } } ret = UserRoleMatrixBiz.InsertOrUpdateValidateData(dataInsert, HttpContext.Current.User.Identity.Name); if (ret) { AppUtil.ClientAlert(Page, "บันทึกข้อมูลสำเร็จ"); SearchValidateData(); } } catch (Exception ex) { string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; _log.Debug(message); AppUtil.ClientAlert(Page, message); } }
private void InitialControl() { cmbScreen.DataSource = UserRoleMatrixBiz.GetScreenList(); cmbScreen.DataTextField = "TextField"; cmbScreen.DataValueField = "ValueField"; cmbScreen.DataBind(); cmbScreen.Items.Insert(0, new ListItem("-------------เลือก-------------", "")); imgResult.Visible = false; btnSave.Visible = false; }
private void SearchValidateData() { if (cmbScreen.SelectedItem.Value == "") { gvResult.DataSource = null; gvResult.DataBind(); imgResult.Visible = false; btnSave.Visible = false; upResult.Update(); } else { txtScreen.Text = cmbScreen.SelectedItem.Value; List <UserRoleMatrixData> uData = UserRoleMatrixBiz.SearchUserRoleMatrix(cmbScreen.SelectedItem.Value); gvResult.DataSource = uData; gvResult.DataBind(); imgResult.Visible = true; btnSave.Visible = true; upResult.Update(); } }