public void BindDDL() { SystemFunction.ListYearsDESC(ddlYear, "", "en-US", "th-TH", short.Parse(System.Configuration.ConfigurationSettings.AppSettings["startYear"].ToString())); int[] arrStatusID = new int[] { }; string sqlFac = ""; int nRole = UserAcc.GetObjUser().nRoleID; int nUserID = UserAcc.GetObjUser().nUserID; if (nRole == 3) // L1 { arrStatusID = new int[] { 1 }; sqlFac = @"SELECT B.ID 'nFacID',B.Name 'sFacName' FROM mTWorkFlow A INNER JOIN mTfacility B ON A.IDFac=B.ID WHERE A.L1=" + nUserID + @" AND B.cDel='N' AND B.cActive='Y' AND B.nLevel=2 GROUP BY B.ID,B.Name ORDER BY B.Name"; } else if (nRole == 4) // L2 { arrStatusID = new int[] { 4, 2 }; //5, 9 sqlFac = @"SELECT B.ID 'nFacID',B.Name 'sFacName' FROM mTWorkFlow A INNER JOIN mTfacility B ON A.IDFac=B.ID WHERE A.L2=" + nUserID + @" AND B.cDel='N' AND B.cActive='Y' AND B.nLevel=2 GROUP BY B.ID,B.Name ORDER BY B.Name"; } else if (nRole == 2) // L0 { arrStatusID = new int[] { 0, 8, 9, 24, 18 }; //0, 8, 9, 24, 18 sqlFac = @"SELECT B.ID 'nFacID',B.Name 'sFacName' FROM mTUser_FacilityPermission A INNER JOIN mTfacility B ON A.nFacilityID=B.ID WHERE A.nUserID=" + nUserID + @"AND A.nRoleID=2 AND A.nPermission IN (2) AND B.cDel='N' AND B.cActive='Y' AND B.nLevel=2 GROUP BY B.ID,B.Name ORDER BY B.Name"; } ddlGroupIndicator.DataSource = db.mTIndicator.OrderBy(o => o.nOrder).ToList(); ddlGroupIndicator.DataValueField = "ID"; ddlGroupIndicator.DataTextField = "Indicator"; ddlGroupIndicator.DataBind(); ddlGroupIndicator.Items.Insert(0, new ListItem("- Select Indicator -", "")); ddlStatus.DataSource = db.TStatus_Workflow.Where(w => arrStatusID.Contains(w.nStatustID)).OrderBy(o => o.sStatusName).ToList(); ddlStatus.DataValueField = "nStatustID"; ddlStatus.DataTextField = "sStatusName"; ddlStatus.DataBind(); ddlStatus.Items.Insert(0, new ListItem("- Select Status -", "")); if (nRole == 2) { ddlStatus.Items.Insert(1, new ListItem("No Action", "-1")); } SystemFunction.ListDBToDropDownList(ddlFacility, sqlFac, "- Select Sub-facility -", "nFacID", "sFacName"); }