예제 #1
0
        public ActionResult Index()
        {
            try
            {
                DataProvider dp = new DataProvider();
                string sql = @"SELECT *
                            FROM quan
                            ORDER BY maquan";
                DataTable dt = new DataTable();

                dt = dp.ExecuteQuery(sql);

                List<Quan> ls = new List<Quan>();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Quan item = new Quan();
                        item.MaQuan = (int)dt.Rows[i]["maquan"];
                        item.TenQuan = (string)dt.Rows[i]["tenquan"];
                        item.MaThanhPho = (int)dt.Rows[i]["mathanhpho"];
                        ls.Add(item);
                    }
                }
                return PartialView("~/Views/Shared/Duong.cshtml", ls);
            }
            catch (Exception ex)
            {
                return PartialView("~/Views/Shared/Duong.cshtml");
            }
        }
예제 #2
0
        public static List<Quan> ListQuan()
        {
            List<Quan> ls = new List<Quan>();
            try
            {
                DataProvider dp = new DataProvider();
                string sql = @"SELECT *
                            FROM quan
                            ORDER BY maquan";
                DataTable dt = new DataTable();

                dt = dp.ExecuteQuery(sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Quan item = new Quan();
                        item.MaQuan = (int)dt.Rows[i]["maquan"];
                        item.TenQuan = (string)dt.Rows[i]["tenquan"];
                        item.MaThanhPho = (int)dt.Rows[i]["mathanhpho"];
                        ls.Add(item);
                    }
                }
                return ls;
            }
            catch (Exception ex)
            {
                return ls;
            }
        }
예제 #3
0
        public void Index(string type, int ma)
        {
            DataProvider dp = new DataProvider();
            type = type.Trim().ToLower();

            if (type.CompareTo("loaddsquan") == 0)
            {
                //Load danh sach thanh pho
                string sql = @"SELECT * FROM quan WHERE mathanhpho = " + ma;
                DataTable dt = new DataTable();
                dt = dp.ExecuteQuery(sql);
                List<Quan> dsQuan = new List<Quan>();

                Response.Write("<option value='0'>Tất cả</option>");

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Quan item = new Quan();
                        item.MaQuan = (int)dt.Rows[i]["maquan"];
                        item.TenQuan = dt.Rows[i]["tenquan"].ToString();
                        item.MaThanhPho = (int)dt.Rows[i]["mathanhpho"];

                        dsQuan.Add(item);

                        Response.Write("<option value='" + item.MaQuan.ToString() + "'>" + item.TenQuan + "</option>");
                    }
                }
            }
            else if (type.CompareTo("loaddsduong") == 0)
            {
                //Load danh sach Duong
                string sql = @"SELECT * FROM duong WHERE maquan = " + ma;
                DataTable dt = new DataTable();
                dt = dp.ExecuteQuery(sql);
                List<Duong> dsDuong = new List<Duong>();

                Response.Write("<option value='0'>Tất cả</option>");

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Duong item = new Duong();
                        item.MaDuong = (int)dt.Rows[i]["maduong"];
                        item.TenDuong = dt.Rows[i]["tenduong"].ToString();
                        item.MaQuan = (int)dt.Rows[i]["maquan"];

                        dsDuong.Add(item);

                        Response.Write("<option value='" + item.MaDuong.ToString() + "'>" + item.TenDuong + "</option>");
                    }
                }
            }
        }
예제 #4
0
        public ActionResult ListQuan(int mathanhpho)
        {
            List<Quan> ls = new List<Quan>();
            try
            {
                DataProvider dp = new DataProvider();
                string sql = @"SELECT *
                            FROM quan
                            WHERE mathanhpho = " + mathanhpho.ToString() + @"
                            ORDER BY maquan";
                DataTable dt = new DataTable();

                dt = dp.ExecuteQuery(sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Quan item = new Quan();
                        item.MaQuan = (int)dt.Rows[i]["maquan"];
                        item.TenQuan = (string)dt.Rows[i]["tenquan"];
                        item.MaThanhPho = (int)dt.Rows[i]["mathanhpho"];
                        ls.Add(item);
                    }
                }
                return Json(ls);
            }
            catch (Exception ex)
            {
                return null;
            }
        }