예제 #1
0
        public string Getddlkhet()
        {
            HttpContext context = HttpContext.Current;

            if (context.Session["USER"] != null)
            {
                Hashtable userDetail = new Hashtable();
                userDetail = (Hashtable)context.Session["USER"];
                user       = new WebManageUserData(userDetail);
                Cs_initaldata inl = new Cs_initaldata(user);

                string options = string.Empty;

                options += "<option value=' '>กรุณาเลือก</option></br>";

                DataTable dt = inl.GetDatabySQL(" SELECT id , name FROM districts ORDER BY id ", user.UserCons);

                foreach (DataRow row in dt.Rows)
                {
                    string code = row[Cs_initaldata.Feild.ID.ToString()].ToString();
                    string name = row[Cs_initaldata.Feild.NAME.ToString()].ToString();

                    options += "<option value='" + code + "'>" + name + "</option></br>";
                }

                var keyValues = new Dictionary <string, string>
                {
                    { "option", options }
                };
                return(JsonConvert.SerializeObject(keyValues));
            }
            return(JsonConvert.SerializeObject(new { redirec = new Cs_manageLoing().GetLoginPage() }));
        }
예제 #2
0
        private void InitialDoctorAutoSuggestion()
        {
            _khet.Attributes.Add("data-live-search", "true");
            _khet.Attributes.Add("data-width", "100%");
            _khet.Attributes.Add("data-size", "12");
            Cs_initaldata inl = new Cs_initaldata(user);

            DataTable dailyDepartments = inl.GetDatabySQL(" SELECT id , name FROM districts ORDER BY id ", user.UserCons);

            if (dailyDepartments.Rows.Count == 0)
            {
                DataRow tempRow = dailyDepartments.NewRow();

                tempRow[Cs_initaldata.Feild.NAME.ToString()] = "ไม่พบหน่วยงาน";
                tempRow[Cs_initaldata.Feild.ID.ToString()]   = "";

                dailyDepartments.Rows.Add(tempRow);
            }
            else
            {
                DataRow tempRow = dailyDepartments.NewRow();

                tempRow[Cs_initaldata.Feild.NAME.ToString()] = "กรุณาเลือกเขต";
                tempRow[Cs_initaldata.Feild.ID.ToString()]   = "0";

                dailyDepartments.Rows.InsertAt(tempRow, 0);
            }

            /*
             * Generate ข้อมูลลง dropdown list
             */
            _khet.DataSource     = dailyDepartments;
            _khet.DataTextField  = Cs_initaldata.Feild.NAME.ToString();
            _khet.DataValueField = Cs_initaldata.Feild.ID.ToString();
            _khet.DataBind();
        }