protected void GenMenu() { cefUser objEfUser = new cefUser(); DataTable dtList = new DataTable(); DataTable dt = new DataTable(); DataRow[] drMenu; DataRow[] drMenu_sub; try { string strCriteria = string.Empty; strCriteria = " And MenuParent = 0 "; strCriteria += " And UserGroupCode= '" + Session["UserGroupCode"] + "'"; strCriteria += " And CanView= 'Y' "; strCriteria += " Order by MenuOrder "; dtList = objEfUser.SP_USER_GROUP_MENU_SEL(strCriteria); strCriteria = " And UserGroupCode='" + Session["UserGroupCode"] + "' "; strCriteria += " And CanView= 'Y' "; strCriteria += " Order by MenuOrder "; dt = objEfUser.SP_USER_GROUP_MENU_SEL(strCriteria); ASPxMenu1.Items.Clear(); for (int i = 0; i < dtList.Rows.Count; i++) { var menuItem = new DevExpress.Web.ASPxMenu.MenuItem(); menuItem.Text = dtList.Rows[i]["MenuName"].ToString(); menuItem.NavigateUrl = dtList.Rows[i]["MenuNavigationUrl"].ToString(); menuItem.Image.Url = Helper.CStr(dtList.Rows[i]["MenuImageUrl"].ToString()); drMenu = dt.Select("MenuParent=" + dtList.Rows[i]["MenuID"].ToString()); for (int j = 0; j < drMenu.Length; j++) { var menuItem_sub = new DevExpress.Web.ASPxMenu.MenuItem(); menuItem_sub.Text = drMenu[j]["MenuName"].ToString(); menuItem_sub.NavigateUrl = drMenu[j]["MenuNavigationUrl"].ToString(); menuItem_sub.Image.Url = drMenu[j]["MenuImageUrl"].ToString(); drMenu_sub = dt.Select("MenuParent=" + drMenu[j]["MenuID"].ToString()); for (int k = 0; k < drMenu_sub.Length; k++) { var menuItem_sub2 = new DevExpress.Web.ASPxMenu.MenuItem(); menuItem_sub2.Text = drMenu_sub[k]["MenuName"].ToString(); menuItem_sub2.NavigateUrl = drMenu_sub[k]["MenuNavigationUrl"].ToString(); menuItem_sub2.Image.Url = drMenu_sub[k]["MenuImageUrl"].ToString(); menuItem_sub.Items.Add(menuItem_sub2); } menuItem.Items.Add(menuItem_sub); } ASPxMenu1.Items.Add(menuItem); } } catch (Exception ex) { MsgBox(ex.Message); } finally { dtList.Dispose(); objEfUser.Dispose(); } }
private bool saveData() { bool blnResult = false; cefUser objEfUser = new cefUser(); try { string strCanView; string strCanInsert; string strCanEdit; string strCanDelete; string strCanApprove; string strCanExtra; if (objEfUser.SP_USER_GROUP_MENU_DEL(cboUserGroup.SelectedValue)) { foreach (GridViewRow row in GridView1.Rows) { 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"); int intMenuId = Helper.CInt(hddMenuID.Value); strCanView = chkCanView.Checked ? "Y" : "N"; strCanInsert = chkCanInsert.Checked ? "Y" : "N"; strCanEdit = chkCanEdit.Checked ? "Y" : "N"; strCanDelete = chkCanDelete.Checked ? "Y" : "N"; strCanApprove = chkCanApprove.Checked ? "Y" : "N"; strCanExtra = chkCanExtra.Checked ? "Y" : "N"; objEfUser.SP_USER_GROUP_MENU_INS(cboUserGroup.SelectedValue, intMenuId, strCanView, strCanInsert, strCanEdit, strCanDelete, strCanApprove, strCanExtra); } } blnResult = true; MsgBox("บันทึกข้อมูลสมบูรณ์"); } catch (Exception ex) { blnResult = false; lblError.Text = ex.Message; } finally { objEfUser.Dispose(); } return(blnResult); }
private bool saveData() { bool blnResult = false; string strUpdatedBy = string.Empty; string struser_group_list = string.Empty; strUpdatedBy = Session["username"].ToString(); CheckBox chkSelect; HiddenField hddg_code; foreach (GridViewRow gvRow in GridView1.Rows) { chkSelect = (CheckBox)gvRow.FindControl("chkSelect"); hddg_code = (HiddenField)gvRow.FindControl("hddg_code"); if (chkSelect.Checked) { struser_group_list += hddg_code.Value + ","; } } if (struser_group_list.Length > 0) { struser_group_list = struser_group_list.Substring(0, struser_group_list.Length - 1); } var objEfUser = new cefUser(); try { #region update if (objEfUser.SP_PERSON_USER_GROUP_UPD(hddperson_code.Value, struser_group_list, txtperson_code.Text, strUpdatedBy)) { blnResult = true; } #endregion } catch (Exception ex) { lblError.Text = ex.Message; } finally { objEfUser.Dispose(); } return(blnResult); }
private void BindGridView() { cefUser objEfUser = new cefUser(); DataTable dt = new DataTable(); try { dt = objEfUser.SP_USER_GROUP_MENU_GROUP(cboUserGroup.SelectedValue); GridView1.DataSource = dt; GridView1.DataBind(); GridView1.Visible = true; imgSaveOnly.Visible = true; } catch (Exception ex) { lblError.Text = ex.Message; } finally { objEfUser.Dispose(); } }