public void Destroy(string[] destroy)
 {
     MyConnectionDB db = new MyConnectionDB();
     foreach (string dt in destroy)
     {
         string sql = string.Format("delete from hoivien where APK = '{0}'", dt);
         db.Execute(sql);
     }
 }
 public void Disable(string[] disable)
 {
     MyConnectionDB db = new MyConnectionDB();
     foreach (string dt in disable)
     {
         string sql = string.Format("update HoiVien set Disable = 1 where APK = '{0}'", dt);
         db.Execute(sql);
     }
 }
 public Page<HoiVien> Search(int page)
 {
     MyConnectionDB db = new MyConnectionDB();
     string sql = "Select * from HoiVien";
     Page<HoiVien> ds;
     ds = db.Page<HoiVien>(page,10,sql);
     Session["page"] = ds.TotalPages;
     return ds;
 }
 public ActionResult Disable(string[] dl, int page)
 {
     MyConnectionDB db = new MyConnectionDB();
     foreach (string dt in dl)
     {
         string sql = string.Format("update HoiVien set Disable = 1 where APK = '{0}'", dt);
         db.Execute(sql);
     }
     var dis = Search(page);
     return Json(dis.Items);
 }
 public ActionResult Destroy(string[] dl, int page)
 {
     MyConnectionDB db = new MyConnectionDB();
     foreach (string dt in dl)
     {
         string sql = string.Format("delete from hoivien where APK = '{0}'", dt);
         db.Execute(sql);
     }
     var dele = Search(page);
     return Json(dele.Items);
 }
        public ActionResult Createmember(DemoModels create)
        {
            int disable = 0;
            if (create.Disable == true)
                disable = 1;
            string sql = "Insert into HoiVien (DivisionID,MemberID,MemberName,ShortName,Address,Identify,Phone,Tel,Fax,Email,Birthday,Website,Mailbox,AreaName,CityName,CountryName,WardName,CountyName,Disable) values (N'" + create.DivisionID + "',N'" + create.MemberID + "',N'" + create.MemberName + "',N'" + create.ShortName + "',N'" + create.Address + "',N'" + create.Identify + "',N'" + create.Phone + "',N'" + create.Tel + "',N'" + create.Fax + "',N'" + create.Email + "',N'" + create.Birthday + "',N'" + create.Website + "',N'" + create.Mailbox + "',N'" + create.AreaName + "',N'" + create.CityName + "',N'" + create.CountryName + "',N'" + create.WardName + "',N'" + create.CountyName + "','" + disable + "')";
            MyConnectionDB db = new MyConnectionDB();
            db.Execute(sql);

            var cr = Search(1);
            return Json(cr.Items);
        }
 public Page<HoiVien> Search1(int page)
 {
     MyConnectionDB db = new MyConnectionDB();
     string sql = "Select * from HoiVien";
     Page<HoiVien> ds;
     HoiVien srch = (HoiVien)TempData["search"];
     string temp = "";
     if (srch.DivisionID != null)
     {
         temp = temp + string.Format(" and DivisionID like N'%{0}%'", srch.DivisionID);
     }
     if (srch.MemberID != null)
     {
         temp = temp + string.Format(" and MemberID like N'%{0}%'", srch.MemberID);
     }
     if (srch.MemberName != null)
     {
         temp = temp + string.Format(" and MemberName like N'%{0}%'", srch.MemberName);
     }
     if (srch.Address != null)
     {
         temp = temp + string.Format(" and Address like N'%{0}%'", srch.Address);
     }
     if (srch.Identify != null)
     {
         temp = temp + string.Format(" and Identify like N'%{0}%'", srch.Identify);
     }
     if (srch.Phone != null)
     {
         temp = temp + string.Format(" and Phone like N'%{0}%'", srch.Phone);
     }
     if (srch.Tel != null)
     {
         temp = temp + string.Format(" and Tel like N'%{0}%'", srch.Tel);
     }
     if (srch.Fax != null)
     {
         temp = temp + string.Format(" and Fax like N'%{0}%'", srch.Fax);
     }
     if (srch.Email != null)
     {
         temp = temp + string.Format(" and Email like N'%{0}%'", srch.Email);
     }
     if (temp != null)
     {
         sql = sql + " where 0=0" + temp;
     }
     ds = db.Page<HoiVien>(page, 10, sql);
     return ds;
 }