private void BindGridView() { cUser_menu objUserMenu = new cUser_menu(); DataSet ds = new DataSet(); string strMessage = string.Empty; string strCriteria = string.Empty; string strloginname = txtloginname.Text; try { strCriteria = " and loginname='" + strloginname + "' "; strCriteria += " And Menu_Status='Y' "; objUserMenu.SP_USER_MENU_MANAGE_SEL(strCriteria, ref ds, ref strMessage); GridView1.DataSource = ds; GridView1.DataBind(); cUser oUser = new cUser(); string strCheck = string.Empty; strCheck = " and [loginname] = '" + txtloginname.Text.Trim() + "' "; if (!oUser.SP_USER_SEL(strCheck, ref ds, ref strMessage)) { lblError.Text = strMessage; } else { if (ds.Tables[0].Rows.Count == 0) { string strScript = "alert('ไม่สามารถบันข้อมูลได้ เนื่องจาก" + "\\nไม่พบข้อมูล Username : "******"');"; MsgBox(strScript); return; } else { this.myDirectorCode = ds.Tables[0].Rows[0]["director_code"].ToString(); this.myUnitCodeList = ds.Tables[0].Rows[0]["unit_code_list"].ToString(); hddperson_group_list.Value = ds.Tables[0].Rows[0]["person_group_list"].ToString(); if (ds.Tables[0].Rows[0]["director_lock"].ToString().Equals("Y")) { chkdirector_lock.Checked = true; } else { chkdirector_lock.Checked = false; } if (ds.Tables[0].Rows[0]["unit_lock"].ToString().Equals("Y")) { chkunit_lock.Checked = true; } else { chkunit_lock.Checked = false; } } } if (GridView1.Rows.Count > 0) { TabContainer1.Visible = true; TabContainer1.ActiveTabIndex = 0; imgSaveOnly.Visible = true; chkdirector_lock.Visible = true; chkunit_lock.Visible = true; } } catch (Exception ex) { lblError.Text = ex.Message.ToString(); } finally { objUserMenu.Dispose(); ds.Dispose(); } }
public void InitUserAccessRight() { string currentUrl = this.GetCurrentUrl(); string strMessage = string.Empty; cUser_menu objUserBLL = new cUser_menu(); DataSet ds = new DataSet(); DataTable table; string strCriteria; if ((currentUrl.IndexOf("Rep_paymentGSJbyyear") > -1) || (currentUrl.IndexOf("Rep_paymentGSJbyyear") > -1)) { strCriteria = " And LoginName='" + UserLoginName + "' And MenuNavigationUrl='Rep_paymentGSJbyyear' "; } else { strCriteria = " And LoginName='" + UserLoginName + "' And MenuNavigationUrl='" + currentUrl + "' "; } objUserBLL.SP_USER_MENU_SEL(strCriteria, ref ds, ref strMessage); if (ds.Tables.Count > 0) { table = ds.Tables[0]; if (table.Rows.Count > 0) { IsUserView = false; IsUserNew = false; IsUserEdit = false; IsUserDelete = false; IsUserApprove = false; IsUserExtra = false; DataRow rowArray = table.Rows[0]; string str6 = rowArray["CanView"].ToString(); string str5 = rowArray["CanInsert"].ToString(); string str3 = rowArray["CanEdit"].ToString(); string str2 = rowArray["CanDelete"].ToString(); string str = rowArray["CanApprove"].ToString(); string str4 = rowArray["CanExtra"].ToString(); if (str == "N" && str2 == "N" && str3 == "N" && str4 == "N" && str5 == "N" && str6 == "N") { Response.Redirect("~/Default.aspx?op=NotAccess"); return; } else { if (str6 == "Y") { IsUserView = true; } if (str5 == "Y") { IsUserNew = true; } if (str3 == "Y") { IsUserEdit = true; } if (str2 == "Y") { IsUserDelete = true; } if (str == "Y") { IsUserApprove = true; } if (str4 == "Y") { IsUserExtra = true; } PageTitle = string.Format("{0} ({1})", rowArray["MenuName"].ToString(), ProgramVersion); PageDes = rowArray["MenuName"].ToString(); } } table.Dispose(); } }
private bool saveData(string strUserID) { bool blnResult = false; string strMessage = string.Empty; string strActive = string.Empty, strCreatedBy = string.Empty, strUpdatedBy = string.Empty; string strScript = string.Empty; int i; cUser_menu oUser_menu = new cUser_menu(); cUser oUser = new cUser(); DataSet ds = new DataSet(); try { string strCanView; string strCanInsert; string strCanEdit; string strCanDelete; string strCanApprove; string strCanExtra; oUser_menu.SP_USER_MENU_DEL(strUserID, ref strMessage); for (i = 0; i <= (GridView1.Rows.Count - 1); i++) { GridViewRow row = GridView1.Rows[i]; HiddenField hddMenuID = (HiddenField)row.FindControl("hddMenuID"); CheckBox chkCanView = (CheckBox)row.FindControl("chkCanView"); CheckBox chkCanInsert = (CheckBox)row.FindControl("chkCanInsert"); CheckBox chkCanEdit = (CheckBox)row.FindControl("chkCanEdit"); CheckBox chkCanDelete = (CheckBox)row.FindControl("chkCanDelete"); CheckBox chkCanApprove = (CheckBox)row.FindControl("chkCanApprove"); CheckBox chkCanExtra = (CheckBox)row.FindControl("chkCanExtra"); string intMenuId = hddMenuID.Value; strCanView = chkCanView.Checked == true ? "Y" : "N"; strCanInsert = chkCanInsert.Checked == true ? "Y" : "N"; strCanEdit = chkCanEdit.Checked == true ? "Y" : "N"; strCanDelete = chkCanDelete.Checked == true ? "Y" : "N"; strCanApprove = chkCanApprove.Checked == true ? "Y" : "N"; strCanExtra = chkCanExtra.Checked == true ? "Y" : "N"; //if (chkCanView.Checked | chkCanInsert.Checked | chkCanEdit.Checked | chkCanDelete.Checked | chkCanApprove.Checked | chkCanExtra.Checked) //{ oUser_menu.SP_USER_MENU_INS(strUserID, intMenuId, strCanView, strCanInsert, strCanEdit, strCanDelete, strCanApprove, strCanExtra, UserLoginName, ref strMessage); // } } string strperson_group_list = string.Empty; for (i = 0; i <= (GridView2.Rows.Count - 1); i++) { GridViewRow row = GridView2.Rows[i]; CheckBox chkPersonGroup = (CheckBox)row.FindControl("chkPersonGroup"); if (chkPersonGroup.Checked) { Label lblperson_group_code = (Label)row.FindControl("lblperson_group_code"); strperson_group_list += lblperson_group_code.Text + ","; } } if (strperson_group_list.Length > 0) { strperson_group_list = strperson_group_list.Substring(0, strperson_group_list.Length - 1); } string strdirector_lock = "N"; if (chkdirector_lock.Checked) { strdirector_lock = "Y"; } string strunit_lock = "N"; if (chkunit_lock.Checked) { strunit_lock = "Y"; } oUser.SP_USER_PERSON_GROUP_UPD(strUserID, strperson_group_list, strdirector_lock, strunit_lock, UserLoginName, ref strMessage); blnResult = true; MsgBox("บันทึกข้อมูลสมบูรณ์"); } catch (Exception ex) { blnResult = false; lblError.Text = ex.Message.ToString(); } finally { oUser_menu.Dispose(); } return(blnResult); }