public IActionResult Create(ChungChi cc)
 {
     try
     {
         if (is_admin)
         {
             SetMetaData(cc, false);
             var chung_chi = ChungChiRepository.Instance.Index(cc);
             if (chung_chi)
             {
                 SetAlert("Thêm chứng chỉ thành công", "success");
             }
             else
             {
                 SetAlert("Thêm chứng chỉ thất bại", "error");
             }
         }
         else
         {
             SetAlert("Bạn không có quyền tạo mới", "error");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     return(View());
 }
        public ActionResult DeleteConfirmed(int id)
        {
            ChungChi chungChi = db.ChungChis.Find(id);

            db.ChungChis.Remove(chungChi);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        protected void grvChungChi_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            var      iD  = (e.Item as GridDataItem).GetDataKeyValue("IDChungChi").ToString();
            int      id  = Convert.ToInt32(iD);
            ChungChi obj = _entities.ChungChis.Where(o => o.IDChungChi == id).First();

            _entities.ChungChis.DeleteObject(obj);
            _entities.SaveChanges();
        }
 public ActionResult Edit([Bind(Include = "MaChungChi,TenChungChi")] ChungChi chungChi)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chungChi).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(chungChi));
 }
Exemple #5
0
        protected void grvChungChi_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            int      id           = Convert.ToInt32(item.GetDataKeyValue("IDChungChi").ToString());
            ChungChi obj          = _entities.ChungChis.Where(o => o.IDChungChi == id).First();

            obj.NgayCapNhat  = DateTime.Now;
            obj.NguoiCapNhat = idNhanVien;
            item.UpdateValues(obj);
            _entities.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "MaChungChi,TenChungChi")] ChungChi chungChi)
        {
            if (ModelState.IsValid)
            {
                db.ChungChis.Add(chungChi);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(chungChi));
        }
Exemple #7
0
 public ActionResult AddCertificate(ChungChi chungChi)
 {
     using (QUANGHANHABCEntities db = new QUANGHANHABCEntities())
     {
         if (chungChi != null)
         {
             db.ChungChis.Add(chungChi);
             db.SaveChanges();
         }
         return(RedirectToAction("List"));
     }
 }
Exemple #8
0
 public ActionResult EditCertificate(ChungChi chungChi)
 {
     using (QUANGHANHABCEntities db = new QUANGHANHABCEntities())
     {
         if (chungChi != null)
         {
             db.Entry(chungChi).State = EntityState.Modified;
             db.SaveChanges();
         }
         return(RedirectToAction("List"));
     }
 }
Exemple #9
0
        public bool Update(ChungChi data)
        {
            if (!string.IsNullOrEmpty(data.ten))
            {
                string id = $"{data.id}";
                data.id       = string.Empty;
                data.ngay_sua = XMedia.XUtil.TimeInEpoch(DateTime.Now);

                return(Update(_default_index, data, id));
            }

            return(false);
        }
Exemple #10
0
        protected void grvChungChi_InsertCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item   = e.Item as GridEditableItem;
            Hashtable        values = new Hashtable();

            item.ExtractValues(values);
            ChungChi obj = new ChungChi();

            obj.NgayTao  = obj.NgayCapNhat = DateTime.Now;
            obj.NguoiTao = obj.NguoiCapNhat = idNhanVien;
            item.UpdateValues(obj);
            _entities.AddToChungChis(obj);
            _entities.SaveChanges();
        }
        // GET: ChungChis/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChungChi chungChi = db.ChungChis.Find(id);

            if (chungChi == null)
            {
                return(HttpNotFound());
            }
            return(View(chungChi));
        }
Exemple #12
0
        private ChungChi ConvertDoc(IHit <ChungChi> hit)
        {
            ChungChi u = new ChungChi();

            try
            {
                u    = hit.Source;
                u.id = hit.Id;
            }
            catch
            {
            }
            return(u);
        }
Exemple #13
0
        public bool Index(ChungChi data)
        {
            int  retry = 0; int max_retry = 5;
            bool need_retry = true;

            if (!string.IsNullOrEmpty(data.ten))
            {
                while (retry++ < max_retry && need_retry)
                {
                    need_retry = !Index(_default_index, data, "");
                    if (need_retry)
                    {
                        Task.Delay(1000).Wait();
                    }
                }
            }
            return(!need_retry);
        }
Exemple #14
0
        public CCMap(ChungChi item, List <ThuocTinh> tt)
        {
            ten           = item.ten;
            mau_chung_chi = item.mau_chung_chi;
            ngay_sua      = item.ngay_sua;
            ngay_tao      = item.ngay_tao;
            nguoi_tao     = item.nguoi_tao;
            nguoi_sua     = item.nguoi_sua;
            id            = item.id;
            var item_thuoc_tinh = new List <int>();

            if (item.thuoc_tinh != null)
            {
                item_thuoc_tinh = item.thuoc_tinh;
            }
            thuoc_tinh = tt.Where(x => item_thuoc_tinh.Contains(x.gia_tri)).ToDictionary(x => x.gia_tri, y => y.ten);
            noi_dung   = item.noi_dung;
        }
 public IActionResult Edit(ChungChi cc)
 {
     try
     {
         SetMetaData(cc, true);
         var chung_chi = ChungChiRepository.Instance.Update(cc);
         if (chung_chi)
         {
             SetAlert("Sửa chứng chỉ thành công", "success");
         }
         else
         {
             SetAlert("Sửa chứng chỉ thất bại", "error");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     return(View());
 }
Exemple #16
0
        public ActionResult EditCertificate(int id = 0)
        {
            using (QUANGHANHABCEntities db = new QUANGHANHABCEntities())
            {
                Dictionary <int, string> list = new Dictionary <int, string>();
                list.Add(1, "Vĩnh viễn");
                list.Add(2, "Thời hạn");

                SelectList listOption = new SelectList(list, "Key", "Value");
                ViewBag.listOption = listOption;
                Dictionary <int, string> listTypes = new Dictionary <int, string>();
                listTypes.Add(1, "Photo");
                listTypes.Add(2, "Sao, Công chứng");
                listTypes.Add(3, "Bản gốc");
                SelectList listTypeCert = new SelectList(listTypes, "Value", "Value");
                ViewBag.listTypeCert = listTypeCert;

                ChungChi chungchi = db.ChungChis.Where(x => x.MaChungChi == id).FirstOrDefault <ChungChi>();
                return(View(chungchi));
            }
        }
Exemple #17
0
        private int themchungchi(int nv_id, int loaichungchi_id, string capdo, string noicap, DateTime ngaycap, string ghichu, int hotro)
        {
            using (var db = new HRMDBEntities())
            {
                var tv = new ChungChi
                {
                    NV_id           = nv_id,
                    LoaiChungChi_id = loaichungchi_id,
                    Capdo           = capdo,
                    NoiCap          = noicap,
                    NgayCap         = ngaycap,
                    GhiChu          = ghichu,
                    HoTro           = hotro,
                    SauKhiVeTruong  = true
                };

                db.ChungChi.Add(tv);
                db.SaveChanges();
                return(tv.id);
            }
        }
Exemple #18
0
        public ActionResult DeleteCertificate(int id = 0)
        {
            using (QUANGHANHABCEntities db = new QUANGHANHABCEntities())
            {
                ChungChi chungChi = db.ChungChis.Where(x => x.MaChungChi == id).FirstOrDefault <ChungChi>();

                db.ChungChis.Remove(chungChi);
                //List<ChungChi_NhanVien> ccnv = new List<ChungChi_NhanVien>();
                var ccnv = from item in db.ChungChi_NhanVien
                           where item.MaChungChi == id
                           select item;
                //var chungchi_nvs = db.ChungChi_NhanVien.Where(x => x.MaChungChi == id).FirstOrDefault<ChungChi_NhanVien>();
                if (ccnv != null)
                {
                    foreach (var item in ccnv)
                    {
                        db.ChungChi_NhanVien.Remove(item);
                    }
                }

                db.SaveChanges();
                return(Json(new { success = true, message = "Delete successful" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #19
0
        protected override void Render(HtmlTextWriter writer)
        {
            StringBuilder sb = new StringBuilder();
            ClientScriptManager cs = this.Page.ClientScript;
            #region Tham số
            String socanbo = Request["SoCanBo"];
            String quymonhamay = Request["QuyMoNhaMay"];
            String xuatkhau = Request["TyLeXuatKhau"];
            String doanhthu = Request["DoanhThuHangNam"];
            String solaodong = Request["SoLaoDong"];
            String vonphapdinh = Request["VonPhapDinh"];
            String spdv = Request["SPDV"];
            String arrthitruong = Request["ThiTruong"];
            String arrchatluong = Request["ChatLuong"];
            String arrloaiDN = Request["LoaiDN"];

            String imgLH = Request["ImageLienHe"];
            String diaChiLH = Request["DiaChiNguoiLienHe"];
            String yahoo = Request["Yahoo"];
            String chucDanh = Request["ChucDanh"];
            String diDong = Request["DiDong"];
            String dienThoai = Request["DienThoai"];
            String emailLienHe = Request["EmailLienHe"];
            String gioiTinh = Request["GioiTinh"];
            String tenLienHe = Request["TenNguoiLienHe"];
            String diaChiNhaMay = Request["DiaChiNhaMay"];
            String chinhanh = Request["ChiNhanhDN"];
            String nguoiDaiDien = Request["NguoiDaiDien"];

            #region Tham so GianHang
            string _GH_ID = Request["ID"];
            string _CQ_ID = Request["CQ_ID"];
            string _TINH_ID = Request["TINH_ID"];
            string _NhomDN_ID = Request["NhomDN_ID"];
            string _LTV_ID = Request["LTV_ID"];
            string _LDN_ID = Request["LDN_ID"];
            string _MEM_ID = Request["MEM_ID"];
            string _Lang = Request["Lang"];
            string _LangBased = Request["LangBased"];
            string _LangBasedId = Request["LangBasedId"];
            string _Ma = Request["Ma"];
            string _Ten = Request["Ten"];
            string _TomTat = Request["TomTat"];
            string _MoTa = Request["MoTa"];
            string _LienHe = Request["LienHe"];
            String _NguoiDaiDien = Request["NguoiDaiDien"];
            string _ChinhSach = Request["ChinhSach"];
            string _Footer = Request["Footer"];
            string _GioiThieu = Request["GioiThieu"];
            string _Anh = Request["Anh"];
            string _Flash = Request["Flash"];
            string _FlashFile = Request["FlashFile"];
            string _FlashWidth = Request["FlashWidth"];
            string _FlashHeight = Request["FlashHeight"];
            string _Slogan = Request["Slogan"];
            string _Banner = Request["Banner"];
            string _BannerType = Request["BannerType"];
            string _DungGiaoDien = Request["DungGiaoDien"];
            string _GD_ID = Request["GD_ID"];
            string _DiaChi = Request["DiaChi"];
            string _website = Request["Website"];
            string _dienthoai = Request["DienthoaiDN"];
            string _Email = Request["Email"];
            string _NamThanhLap = Request["NamThanhLap"];
            string _ToaDo = Request["ToaDo"];
            string _Xem = Request["Xem"];
            string _BinhChon = Request["BinhChon"];
            string _Diem = Request["Diem"];
            string _Hotline = Request["Hotline"];
            string _NgayTao = Request["NgayTao"];
            string _NgayCapNhat = Request["NgayCapNhat"];
            string _KichHoat = Request["KichHoat"];
            string _NgayKichHoat = Request["NgayKichHoat"];
            string _DamBao = Request["DamBao"];
            string _NgayDamBao = Request["NgayDamBao"];
            string _rows_id = Request["Rows_ID"];
            string _q = Request["q"];
            string _startDateLTV = Request["GH_NgayBatDau"];
            string _endDateLTV = Request["GH_NgayKetThuc"];
            string ldm_ma = Request["LDM_Ma"];
            #endregion
            #region Tham so ChungChi
            string _cc_id = Request["CC_ID"];
            string _cc_gh_id = Request["CC_GH_ID"];
            string _cc_thutu = Request["CC_TT"];
            string _cc_anh = Request["CC_Anh"];
            string _cc_ten = Request["CC_Ten"];
            string _cc_so = Request["CC_So"];
            string _cc_gioihan = Request["CC_GioiHan"];
            string _cc_donvicap = Request["CC_DonViCap"];
            string _cc_ngaycap = Request["CC_NgayCap"];
            string _cc_active = Request["CC_Active"];
            #endregion
            #region Tham so ThuVien
            string _tv_id = Request["TV_ID"];
            string _tv_gh_id = Request["TV_GH_ID"];
            string _tv_ten = Request["TV_Ten"];
            string _tv_mota = Request["TV_Mota"];
            string _tv_keyword = Request["TV_Keyword"];
            string _tv_UrlImage = Request["TV_UrlImage"];
            string _tv_Url = Request["TV_Url"];
            string _tv_thutu = Request["TV_Thutu"];
            string _tv_loai = Request["TV_Loai"];
            string _tv_ngaytao = Request["TV_Ngaytao"];
            string _tv_active = Request["TV_Active"];
            string _tv_nguoitao = Request["TV_NguoiTao"];
            string _rows = Request["rows"];
            #endregion
            #region Tham so Flash
            string _flh_id = Request["Flh_ID"];
            string _flh_gh_id = Request["Flh_GH_ID"];
            string _flh_vitri = Request["Flh_Vitri"];
            string _flh_ten = Request["Flh_Ten"];
            string _flh_mota = Request["Flh_Mota"];
            string _flh_pathimg = Request["Flh_UrlImage"];
            string _flh_pathflash = Request["Flh_Url"];
            string _flh_link = Request["Flh_Link"];
            string _flh_thutu = Request["Flh_Thutu"];
            string _flh_nguoitao = Request["Flh_NguoiTao"];
            string _flh_ngaytao = Request["Flh_NgayTao"];
            string _flh_active = Request["Flh_Active"];
            #endregion
            #region Tham so Hình Ảnh doanh nghiệp
            string _ha_id = Request["HA_ID"];
            string _ha_gh_id = Request["HA_GH_ID"];
            string _ha_vitri = Request["HA_Vitri"];
            string _ha_ten = Request["HA_Ten"];
            string _ha_mota = Request["HA_Mota"];
            string _ha_pathimg = Request["HA_UrlImage"];
            string _ha_link = Request["HA_Link"];
            string _ha_nguoitao = Request["HA_NguoiTao"];
            string _ha_ngaytao = Request["HA_NgayTao"];
            string _ha_active = Request["HA_Active"];
            #endregion

            string lienhe = "";
            string msgDN = Request["NoiDungLienHeDN"];
            string Repass = Request["RePass"];
            sendEmailDele _dele = new sendEmailDele(sendmailThongbao);
            #endregion

            switch (subAct)
            {

                case "getChuaDuyet":
                    #region Get du lieu cho grid
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "ID";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";
                    Pager<GianHang> PageGet = GianHangDal.pagerNormal("", false, "GH_" + jgrsidx + " " + jgrsord, "0", "1", _q, _NhomDN_ID, _TINH_ID, _LTV_ID, _LDN_ID, "", Request["rows"]);
                    List<jgridRow> ListRow = new List<jgridRow>();
                    int a = 0;
                    foreach (GianHang gh in PageGet.List)
                    {
                        a = a + 1;
                        ListRow.Add(new jgridRow(gh.ID.ToString(),
                             new string[] {
                                    gh.ID.ToString(),
                                    a.ToString(),
                                    string.Format(gh.Ten==null?"":gh.Ten),
                                    string.Format(gh.DiaChi==null? "":gh.DiaChi),
                                    string.Format(gh.TenTinh==null?"":gh.TenTinh),
                                    gh.NgayTao.ToString("dd/MM/yyyy"),
                                    gh.NguoiTao,
                                    string.Format(gh.Website==null?"":gh.Website),
                                    string.Format(gh.LH_Ten==null?"":gh.LH_Ten),
                                    string.Format(gh.LH_Mobile==null?"":gh.LH_Mobile),
                                    //string.Format(DanhMucDal.SelectById(gh.LTV_ID)==null? "":DanhMucDal.SelectById(gh.LTV_ID).Ma),
                                    string.Format(gh.NguoiDaiDien==null?"":gh.NguoiDaiDien),
                                    string.Format(MemberDal.SelectAllByUserName(gh.NguoiTao).Email==null?"":MemberDal.SelectAllByUserName(gh.NguoiTao).Email),
                                    string.Format(gh.DienThoai==null?"":gh.DienThoai)

                                 }));
                    }
                    jgrid grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PageGet.TotalPages.ToString(), PageGet.Total.ToString(), ListRow);
                    sb.Append(JavaScriptConvert.SerializeObject(grid));
                    break;
                    #endregion
                case "getDuyet":
                    #region Get du lieu cho grid
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "NgayTao";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";
                    Pager<GianHang> PageGetDuyet = GianHangDal.pagerNormal("", false, "GH_" + jgrsidx + " " + jgrsord, "1", "1", _q, _NhomDN_ID, _TINH_ID, _LTV_ID, _LDN_ID, "", Request["rows"]);
                    List<jgridRow> ListRowDuyet = new List<jgridRow>();
                    int b = 0;
                    foreach (GianHang gh in PageGetDuyet.List)
                    {
                        b = b + 1;
                        ListRowDuyet.Add(new jgridRow(gh.ID.ToString(),
                             new string[] {
                                    gh.ID.ToString(),
                                    b.ToString(),
                                    string.Format(gh.Ten==null?"":gh.Ten),
                                    string.Format(gh.DiaChi==null? "":gh.DiaChi),
                                    string.Format(gh.TenTinh==null?"":gh.TenTinh),
                                    gh.NgayTao.ToString("dd/MM/yyyy"),
                                    gh.NguoiTao,
                                    string.Format(gh.Website==null?"":gh.Website),
                                    string.Format(gh.LH_Ten==null?"":gh.LH_Ten),
                                    string.Format(gh.LH_Mobile==null?"":gh.LH_Mobile),
                                    string.Format(gh.NguoiDaiDien==null?"":gh.NguoiDaiDien),
                                    string.Format(MemberDal.SelectAllByUserName(gh.NguoiTao).Email==null?"":MemberDal.SelectAllByUserName(gh.NguoiTao).Email),
                                    string.Format(gh.DienThoai==null?"":gh.DienThoai)

                                 }));
                    }
                    jgrid gridDuyet = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PageGetDuyet.TotalPages.ToString(), PageGetDuyet.Total.ToString(), ListRowDuyet);
                    sb.Append(JavaScriptConvert.SerializeObject(gridDuyet));
                    break;
                    #endregion
                case "getTVV":
                    #region Get du lieu cho grid
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "NgayTao";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";

                    Pager<GianHang> PageGetTVV = GianHangDal.pagerNormal("", false, "GH_" + jgrsidx + " " + jgrsord, "1", "1", _q, _NhomDN_ID, _TINH_ID, _LTV_ID, _LDN_ID, "TV_VANG", Request["rows"]);
                    List<jgridRow> ListRowTVV = new List<jgridRow>();
                    int c = 0;
                    foreach (GianHang gh in PageGetTVV.List)
                    {
                        c = c + 1;
                        ListRowTVV.Add(new jgridRow(gh.ID.ToString(),
                             new string[] {
                                    gh.ID.ToString(),
                                    c.ToString(),
                                    string.Format(gh.Ten==null?"":gh.Ten),
                                    string.Format(gh.DiaChi==null? "":gh.DiaChi),
                                    string.Format(gh.TenTinh==null?"":gh.TenTinh),
                                    gh.NgayTao.ToString("dd/MM/yyyy"),
                                    gh.NguoiTao,
                                    string.Format(gh.Website==null?"":gh.Website),
                                    string.Format(gh.LH_Ten==null?"":gh.LH_Ten),
                                    string.Format(gh.LH_Mobile==null?"":gh.LH_Mobile),
                                    string.Format(gh.NguoiDaiDien==null?"":gh.NguoiDaiDien),
                                    string.Format(MemberDal.SelectAllByUserName(gh.NguoiTao).Email==null?"":MemberDal.SelectAllByUserName(gh.NguoiTao).Email),
                                    string.Format(gh.DienThoai==null?"":gh.DienThoai)

                                 }));
                    }
                    jgrid gridTVV = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PageGetTVV.TotalPages.ToString(), PageGetTVV.Total.ToString(), ListRowTVV);
                    sb.Append(JavaScriptConvert.SerializeObject(gridTVV));
                    break;
                    #endregion
                case "getTVB":
                    #region Get du lieu cho grid
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "NgayTao";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";

                    Pager<GianHang> PageGetTVB = GianHangDal.pagerNormal("", false, "GH_" + jgrsidx + " " + jgrsord, "1", "1", _q, _NhomDN_ID, _TINH_ID, _LTV_ID, _LDN_ID, "TV_BAC", Request["rows"]);
                    List<jgridRow> ListRowTVB = new List<jgridRow>();
                    int d = 0;
                    foreach (GianHang gh in PageGetTVB.List)
                    {
                        d = d + 1;
                        ListRowTVB.Add(new jgridRow(gh.ID.ToString(),
                             new string[] {
                                    gh.ID.ToString(),
                                    d.ToString(),
                                    string.Format(gh.Ten==null?"":gh.Ten),
                                    string.Format(gh.DiaChi==null? "":gh.DiaChi),
                                    string.Format(gh.TenTinh==null?"":gh.TenTinh),
                                    gh.NgayTao.ToString("dd/MM/yyyy"),
                                    gh.NguoiTao,
                                    string.Format(gh.Website==null?"":gh.Website),
                                    string.Format(gh.LH_Ten==null?"":gh.LH_Ten),
                                    string.Format(gh.LH_Mobile==null?"":gh.LH_Mobile),
                                    string.Format(gh.NguoiDaiDien==null?"":gh.NguoiDaiDien),
                                    string.Format(MemberDal.SelectAllByUserName(gh.NguoiTao).Email==null?"":MemberDal.SelectAllByUserName(gh.NguoiTao).Email),
                                    string.Format(gh.DienThoai==null?"":gh.DienThoai)

                                 }));
                    }
                    jgrid gridTVB = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PageGetTVB.TotalPages.ToString(), PageGetTVB.Total.ToString(), ListRowTVB);
                    sb.Append(JavaScriptConvert.SerializeObject(gridTVB));
                    break;
                    #endregion
                case "getTVD":
                    #region Get du lieu cho grid
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "NgayTao";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";

                    Pager<GianHang> PageGetTVD = GianHangDal.pagerNormal("", false, "GH_" + jgrsidx + " " + jgrsord, "1", "1", _q, _NhomDN_ID, _TINH_ID, _LTV_ID, _LDN_ID, "TV_DONG", Request["rows"]);
                    List<jgridRow> ListRowTVD = new List<jgridRow>();
                    int e = 0;
                    foreach (GianHang gh in PageGetTVD.List)
                    {
                        e = e + 1;
                        ListRowTVD.Add(new jgridRow(gh.ID.ToString(),
                             new string[] {
                                    gh.ID.ToString(),
                                    e.ToString(),
                                    string.Format(gh.Ten==null?"":gh.Ten),
                                    string.Format(gh.DiaChi==null? "":gh.DiaChi),
                                    string.Format(gh.TenTinh==null?"":gh.TenTinh),
                                    gh.NgayTao.ToString("dd/MM/yyyy"),
                                    gh.NguoiTao,
                                    string.Format(gh.Website==null?"":gh.Website),
                                    string.Format(gh.LH_Ten==null?"":gh.LH_Ten),
                                    string.Format(gh.LH_Mobile==null?"":gh.LH_Mobile),
                                    string.Format(gh.NguoiDaiDien==null?"":gh.NguoiDaiDien),
                                    string.Format(MemberDal.SelectAllByUserName(gh.NguoiTao).Email==null?"":MemberDal.SelectAllByUserName(gh.NguoiTao).Email),
                                    string.Format(gh.DienThoai==null?"":gh.DienThoai)

                                 }));
                    }
                    jgrid gridTVD = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PageGetTVD.TotalPages.ToString(), PageGetTVD.Total.ToString(), ListRowTVD);
                    sb.Append(JavaScriptConvert.SerializeObject(gridTVD));
                    break;
                    #endregion

                case "getTVMP":
                    #region Get du lieu cho grid
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "NgayTao";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";

                    Pager<GianHang> PageGetTVMP = GianHangDal.pagerNormal("", false, "GH_" + jgrsidx + " " + jgrsord, "1", "1", _q, _NhomDN_ID, _TINH_ID, _LTV_ID, _LDN_ID, "TV_FREE", Request["rows"]);
                    List<jgridRow> ListRowTVMP = new List<jgridRow>();
                    int f = 0;
                    foreach (GianHang gh in PageGetTVMP.List)
                    {
                        f = f + 1;
                        ListRowTVMP.Add(new jgridRow(gh.ID.ToString(),
                             new string[] {
                                    gh.ID.ToString(),
                                    f.ToString(),
                                    string.Format(gh.Ten==null?"":gh.Ten),
                                    string.Format(gh.DiaChi==null? "":gh.DiaChi),
                                    string.Format(gh.TenTinh==null?"":gh.TenTinh),
                                    gh.NgayTao.ToString("dd/MM/yyyy"),
                                    gh.NguoiTao,
                                    string.Format(gh.Website==null?"":gh.Website),
                                    string.Format(gh.LH_Ten==null?"":gh.LH_Ten),
                                    string.Format(gh.LH_Mobile==null?"":gh.LH_Mobile),
                                    string.Format(gh.NguoiDaiDien==null?"":gh.NguoiDaiDien),
                                    string.Format(MemberDal.SelectAllByUserName(gh.NguoiTao).Email==null?"":MemberDal.SelectAllByUserName(gh.NguoiTao).Email),
                                    string.Format(gh.DienThoai==null?"":gh.DienThoai)

                                 }));
                    }
                    jgrid gridTVMP = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PageGetTVMP.TotalPages.ToString(), PageGetTVMP.Total.ToString(), ListRowTVMP);
                    sb.Append(JavaScriptConvert.SerializeObject(gridTVMP));
                    break;
                    #endregion
                case "getTVBK":
                    #region Get du lieu cho grid
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "NgayTao";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";

                    Pager<GianHang> PageGetTVK = GianHangDal.pagerNormal("", false, "GH_" + jgrsidx + " " + jgrsord, null, "0", _q, _NhomDN_ID, _TINH_ID, _LTV_ID, _LDN_ID, "TV_FREE", Request["rows"]);
                    List<jgridRow> ListRowTVK = new List<jgridRow>();
                    int g = 0;
                    foreach (GianHang gh in PageGetTVK.List)
                    {
                        g = g + 1;
                        ListRowTVK.Add(new jgridRow(gh.ID.ToString(),
                             new string[] {
                                    gh.ID.ToString(),
                                    g.ToString(),
                                    string.Format(gh.Ten==null?"":gh.Ten),
                                    string.Format(gh.DiaChi==null? "":gh.DiaChi),
                                    string.Format(gh.TenTinh==null?"":gh.TenTinh),
                                    gh.NgayTao.ToString("dd/MM/yyyy"),
                                    gh.NguoiTao,
                                    string.Format(gh.Website==null?"":gh.Website),
                                    string.Format(gh.LH_Ten==null?"":gh.LH_Ten),
                                    string.Format(gh.LH_Mobile==null?"":gh.LH_Mobile),
                                    string.Format(gh.NguoiDaiDien==null?"":gh.NguoiDaiDien),
                                    string.Format(MemberDal.SelectAllByUserName(gh.NguoiTao).Email==null?"":MemberDal.SelectAllByUserName(gh.NguoiTao).Email),
                                    string.Format(gh.DienThoai==null?"":gh.DienThoai)

                                 }));
                    }
                    jgrid gridTVK = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PageGetTVK.TotalPages.ToString(), PageGetTVK.Total.ToString(), ListRowTVK);
                    sb.Append(JavaScriptConvert.SerializeObject(gridTVK));
                    break;
                    #endregion
                case "NangCapThanhVien":
                    #region
                    if (!string.IsNullOrEmpty(_GH_ID))
                    {
                        sb.Append("(" + JavaScriptConvert.SerializeObject(GianHangDal.SelectByGh_IdAndLdm_ma(Convert.ToInt32(_GH_ID), "TV_LOAI")) + ")");
                    }
                    break;
                    #endregion
                case "boxacnhan":
                    #region
                    if (!string.IsNullOrEmpty(_GH_ID))
                    {
                        GianHangDal.Xacnhan(_GH_ID, "0", "1");
                    }
                    foreach (LienHe lh in LienHeDal.SelectByActive(true))
                    {
                        lienhe += lh.Ten.ToString() + ", Điện thoại: " + lh.Mobile + ", Email: " + lh.Email + "<br/>";
                    }
                    foreach (GianHang item in GianHangDal.SelectByListId(_GH_ID))
                    {
                        _dele.BeginInvoke(item.Email
                            , string.Format("Thống báo từ chonongnghiep.com")
                            , string.Format(inviMailBody
                                            , item.Ten
                                            , item.DiaChi
                                            , item.Email
                                            , string.Format("bỏ xác nhận")
                                            , DateTime.Now
                                            , lienhe.ToString()
                                            )
                            , null, null);
                    }
                    break;
                    #endregion

                case "saveNangCapLTV":
                    #region lưu dữ liệu thông tin doanh nghiệp
                    GianHang ghItem = new GianHang();
                    Relation rltItem = new Relation();
                    //update vào gian hàng
                    string LTV_Ma = DanhMucDal.SelectById(int.Parse(_LTV_ID)).Ma;
                    ghItem = GianHangDal.SelectById(int.Parse(_GH_ID));
                    if (LTV_Ma == "TV_VANG")
                    {
                        ghItem.NgayDKTV_Vang = Convert.ToDateTime(_startDateLTV,new CultureInfo("vi-vn"));
                        ghItem.NgayKTTV_Vang = Convert.ToDateTime(_endDateLTV, new CultureInfo("vi-vn"));
                    }
                    if (LTV_Ma == "TV_BAC")
                    {
                        ghItem.NgayDKTV_Bac = Convert.ToDateTime(_startDateLTV, new CultureInfo("vi-vn"));
                        ghItem.NgayKTTV_Bac = Convert.ToDateTime(_endDateLTV, new CultureInfo("vi-vn"));
                    }
                    if (LTV_Ma == "TV_DONG")
                    {
                        ghItem.NgayDKTV_Dong = Convert.ToDateTime(_startDateLTV, new CultureInfo("vi-vn"));
                        ghItem.NgayKTTV_Dong = Convert.ToDateTime(_endDateLTV, new CultureInfo("vi-vn"));
                    }

                    ghItem.LTV_ID = int.Parse(_LTV_ID);
                    ghItem = GianHangDal.Update(ghItem);

                    //combox, check box Insert vào tblRelation
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(_LTV_ID, ghItem.RowId.ToString(), "TV_LOAI");

                    break;
                    #endregion
                case "editGianHang":
                    #region Edit doanh nghiệp
                    if (!string.IsNullOrEmpty(_GH_ID))
                    {
                        sb.Append("(" + JavaScriptConvert.SerializeObject(GianHangDal.SelectDmIdByGhId(Convert.ToInt32(_GH_ID))) + ")");
                    }
                    break;
                    #endregion
                case "LoadThongTinDN":
                    #region load thong tin doanh nghiep( gian hang)
                    sb.Append("(" + JavaScriptConvert.SerializeObject(GianHangDal.SelectDmIdByGhId(int.Parse(_GH_ID))) + ")");
                    break;
                    #endregion

                case "loadDM":
                    #region load hỗ trợ đăng ký doanh nghiệp
                    sb.Append(JavaScriptConvert.SerializeObject(DanhMucDal.SelectLangBasedByPID("", ldm_ma, "0")));
                    break;
                    #endregion
                case "infoBusinessSave":
                    #region lưu dữ liệu thông tin doanh nghiệp
                    GianHang itemGH = new GianHang();
                    Relation itemRLT = new Relation();
                    LienHe itemLH = new LienHe();
                    //update vào gian hàng
                    itemGH = GianHangDal.SelectById(int.Parse(_GH_ID));
                    itemGH.ID = itemGH.ID;
                    itemGH.Anh = _Anh;
                    itemGH.MoTa = _MoTa;
                    if (_website != "http://" || _website != null)
                    {
                        itemGH.Website = _website;
                    }
                    itemGH.Ten = _Ten;
                    itemGH.DiaChi = _DiaChi;
                    itemGH.NguoiDaiDien = _NguoiDaiDien;
                    itemGH.TomTat = _TomTat;
                    itemGH.GioiThieu = _GioiThieu;
                    itemGH.Active = true;
                    itemGH.DamBao = false;
                    itemGH.DienThoai = _dienthoai;
                    itemGH.NamThanhLap = int.Parse(_NamThanhLap);
                    itemGH.ActiveDate = DateTime.Now;
                    itemGH.NgayTao = DateTime.Now;
                    itemGH.TINH_ID = int.Parse(_TINH_ID);
                    itemGH.LTV_ID = 11021;
                    itemGH = GianHangDal.Update(itemGH);
                    //Save vào tblLienHe Người liên hệ
                    itemLH = LienHeDal.SelectByGhId(int.Parse(_GH_ID));
                    if (gioiTinh == "Nam")
                    {
                        itemLH.GioiTinh = true;
                    }
                    else
                    {
                        itemLH.GioiTinh = false;
                    }
                    itemLH.Ten = tenLienHe;
                    itemLH.Email = emailLienHe;
                    itemLH.Phone = dienThoai;
                    itemLH.Mobile = diDong;
                    itemLH.ChucDanh = chucDanh;
                    itemLH.Ym = yahoo;
                    itemLH.DiaChi = diaChiLH;
                    itemLH.Anh = imgLH;
                    itemLH.NgayCapNhat = DateTime.Now;
                    itemLH.NguoiCapNhat = Security.Username;
                    itemLH.Active = true;
                    itemLH = LienHeDal.Update(itemLH);

                    //itemLH = LienHeDal.Insert(itemLH);
                    //combox, check box Insert vào tblRelation

                    //Relation_danhMuc_GianHangDal.InsertArrDMByGianHang("11019", itemGH.RowId.ToString(), "TV_LOAI");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(arrchatluong, itemGH.RowId.ToString(), "TV_ISO");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(arrthitruong, itemGH.RowId.ToString(), "TV_TTRUONG");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(arrloaiDN, itemGH.RowId.ToString(), "DN_LOAI");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(vonphapdinh, itemGH.RowId.ToString(), "TV_VON");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(spdv, itemGH.RowId.ToString(), "SP_NHOM");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(_TINH_ID, itemGH.RowId.ToString(), "KV_TINH");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(solaodong, itemGH.RowId.ToString(), "TV_LD");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(socanbo, itemGH.RowId.ToString(), "TV_R&D");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(doanhthu, itemGH.RowId.ToString(), "TV_DTHU");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(xuatkhau, itemGH.RowId.ToString(), "TV_XK");
                    Relation_danhMuc_GianHangDal.InsertArrDMByGianHang(quymonhamay, itemGH.RowId.ToString(), "TV_QUYMONM");
                    break;
                    #endregion
                case "EmailMember":
                    sb.Append(JavaScriptConvert.SerializeObject(MemberDal.SelectByUser(Security.Username)));
                    break;
                case "getPid":
                    #region get Setautocomplete gian hang
                    GianHang _GHItem = new GianHang();
                    _GHItem.ID = 0;
                    _GHItem.Ten = "Chọn";
                    GianHangCollection ListGetPid = new GianHangCollection();
                    ListGetPid = GianHangDal.SelectTree(_q);
                    ListGetPid.Insert(0, _GHItem);
                    sb.Append(JavaScriptConvert.SerializeObject(ListGetPid));
                    break;
                    #endregion
                case "lienHeDN":
                    #region lienheDN
                    foreach (LienHe lh in LienHeDal.SelectByActive(true))
                    {
                        lienhe += lh.Ten.ToString() + ", Điện thoại: " + lh.Mobile + ", Email: " + lh.Email + "<br/>";
                    }
                    foreach (GianHang item in GianHangDal.SelectByListId(_GH_ID))
                    {
                        _dele.BeginInvoke(item.Email
                            , string.Format("Thông báo từ chonongnghiep.com")
                            , string.Format(NoiDungLienHeDN
                                            , item.Ten
                                            , item.DiaChi
                                            , item.Email
                                            , msgDN
                                            , lienhe.ToString()
                                            )
                            , null, null);
                    }
                    break;
                    #endregion
                case "xacnhan":
                    #region
                    if (!string.IsNullOrEmpty(_GH_ID))
                    {
                        GianHangDal.Xacnhan(_GH_ID, "1", "1");
                    }
                    foreach (LienHe lh in LienHeDal.SelectByActive(true))
                    {
                        lienhe += lh.Ten.ToString() + ", Điện thoại: " + lh.Mobile + ", Email: " + lh.Email + "<br/>";
                    }
                    foreach (GianHang item in GianHangDal.SelectByListId(_GH_ID))
                    {
                        _dele.BeginInvoke(item.Email
                            , string.Format("Thống báo từ chonongnghiep.com")
                            , string.Format(inviMailBody
                                            , item.Ten
                                            , item.DiaChi
                                            , item.Email
                                            , string.Format("được xác nhận")
                                            , DateTime.Now
                                            , lienhe.ToString()
                                            )
                            , null, null);
                    }
                    break;
                    #endregion
                case "Active":
                    #region
                    if (!string.IsNullOrEmpty(_GH_ID))
                    {
                        GianHangDal.DungGH(_GH_ID, "0", DateTime.Now.ToString());
                    }
                    foreach (LienHe lh in LienHeDal.SelectByActive(true))
                    {
                        lienhe += "  - " + lh.Ten.ToString() + ", Điện thoại: " + lh.Mobile + ", Email: " + lh.Email + "<br/>";
                    }
                    foreach (GianHang item in GianHangDal.SelectByListId(_GH_ID))
                    {
                        _dele.BeginInvoke(item.Email
                            , string.Format("Thống báo từ chonongnghiep.com")
                            , string.Format(inviMailBody
                                            , item.Ten
                                            , item.DiaChi
                                            , item.Email
                                            , string.Format("bị khóa")
                                            , DateTime.Now
                                            , lienhe.ToString()
                                           )
                            , null, null);
                    }

                    break;
                    #endregion
                case "ActiveTVBK":
                    #region
                    if (!string.IsNullOrEmpty(_GH_ID))
                    {
                        GianHangDal.DungGH(_GH_ID, "1", DateTime.Now.ToString());
                    }
                    foreach (LienHe lh in LienHeDal.SelectByActive(true))
                    {
                        lienhe += "  - " + lh.Ten.ToString() + ", Điện thoại: " + lh.Mobile + ", Email: " + lh.Email + "<br/>";
                    }
                    foreach (GianHang item in GianHangDal.SelectByListId(_GH_ID))
                    {
                        _dele.BeginInvoke(item.Email
                            , string.Format("Thống báo từ chonongnghiep.com")
                            , string.Format(inviMailBody
                                            , item.Ten
                                            , item.DiaChi
                                            , item.Email
                                            , string.Format("được kích hoạt")
                                            , DateTime.Now
                                            , lienhe.ToString()
                                           )
                            , null, null);
                    }

                    break;
                    #endregion
                case "del":
                    #region xóa
                    if (!string.IsNullOrEmpty(_GH_ID))
                    {
                        GianHangDal.DeleteByIdList(_GH_ID);
                    }
                    foreach (LienHe lh in LienHeDal.SelectByActive(true))
                    {
                        lienhe += lh.Ten.ToString() + ", Điện thoại: " + lh.Mobile + ", Email: " + lh.Email + "<br/>";
                    }
                    foreach (GianHang item in GianHangDal.SelectByListId(_GH_ID))
                    {
                        _dele.BeginInvoke(item.Email
                            , string.Format("Thống báo từ chonongnghiep.com")
                            , string.Format(inviMailBody
                                            , item.Ten
                                            , item.DiaChi
                                            , item.Email
                                            , string.Format("bị xóa")
                                            , DateTime.Now
                                            , lienhe.ToString()
                                            )
                            , null, null);
                    }
                    break;
                    #endregion
                case "getChungChi":
                    #region get chung chi
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "CC_ID";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "desc";
                    Pager<ChungChi> PagerGetCC = ChungChiDal.pagerNormal("", false, jgrsidx + " " + jgrsord, _q, Request["rows"], _cc_gh_id);
                    List<jgridRow> ListRowCC = new List<jgridRow>();
                    foreach (ChungChi cc in PagerGetCC.List)
                    {
                        ListRowCC.Add(new jgridRow(cc.ID.ToString(),
                            new string[] {
                                cc.ID.ToString(),
                                cc.TT.ToString(),
                                string.Format(@"<img src=""../up/i/{0}"" />",Lib.imgSize(cc.Anh,"50x50")),
                                cc.Ten.ToString(),
                                cc.So,
                                cc.GioiHan,
                                cc.DonViCap,
                                cc.NgayCap.ToString("dd/MM/yyyy"),
                                cc.Active.ToString()
                                 }));
                    }
                    grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PagerGetCC.TotalPages.ToString(), PagerGetCC.Total.ToString(), ListRowCC);
                    sb.Append(JavaScriptConvert.SerializeObject(grid));
                    break;
                    #endregion
                case "editChungChi":
                    #region Edit chứng chỉ
                    if (!string.IsNullOrEmpty(_cc_id))
                    {
                        sb.Append("(" + JavaScriptConvert.SerializeObject(ChungChiDal.SelectById(Convert.ToInt32(_cc_id))) + ")");
                    }
                    break;
                    #endregion
                case "delChungChi":
                    #region xóa
                    if (!string.IsNullOrEmpty(_cc_id))
                    {
                        ChungChiDal.DeleteByIdList(_cc_id);
                    }
                    break;
                    #endregion
                case "ActiveChungChi":
                    #region active Chứng chỉ
                    if (!string.IsNullOrEmpty(_cc_id))
                    {
                        ChungChiDal.ActiveCC(_cc_id, "1");
                    }
                    break;
                    #endregion
                case "saveChungChi":
                    #region luu chung chi
                    ChungChi ItemSave = new ChungChi();

                    if (string.IsNullOrEmpty(_cc_ten))
                    {
                        sb.Append("0");
                        break;
                    }
                    if (!string.IsNullOrEmpty(_cc_id))
                    {
                        ItemSave = ChungChiDal.SelectById(Convert.ToInt32(_cc_id));
                    }
                    ItemSave.TT = int.Parse(_cc_thutu);
                    ItemSave.GH_ID = int.Parse(_cc_gh_id);
                    ItemSave.Ten = _cc_ten;
                    ItemSave.So = _cc_so;
                    ItemSave.NgayCap = Convert.ToDateTime(_cc_ngaycap, new CultureInfo("vi-vn"));
                    ItemSave.GioiHan = _cc_gioihan;
                    ItemSave.DonViCap = _cc_donvicap;
                    ItemSave.Anh = _cc_anh;
                    ItemSave.Active = Convert.ToBoolean(_cc_active);

                    if (!string.IsNullOrEmpty(_cc_id))
                    {
                        ItemSave = ChungChiDal.Update(ItemSave);
                    }
                    else
                    {
                        ItemSave = ChungChiDal.Insert(ItemSave);
                    }
                    sb.Append("1");
                    break;
                    #endregion
                case "getVideo":
                    #region lấy danh sách
                    if (string.IsNullOrEmpty(jgRows)) jgRows = "10";
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "TV_Thutu";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "asc";
                    Pager<Thuvien> PagerGet = ThuvienDal.pagerNormal("", false, jgrsidx + " " + jgrsord
                       , int.Parse(_rows)
                       , Request["q"]
                       , _CQ_ID
                       , 0
                       , _tv_nguoitao
                       , _tv_gh_id);
                    List<jgridRow> ListRowVideo = new List<jgridRow>();
                    foreach (Thuvien item in PagerGet.List)
                    {
                        ListRowVideo.Add(new jgridRow(item.ID.ToString(), new string[]{
                            item.ID.ToString()
                            ,(item.Thutu.ToString())
                            ,string.Format("<img class=\"adm-pro-icon\" src=\"../up/v/{0}\" />", string.IsNullOrEmpty(item.UrlImage) ? "no-image.png" :item.UrlImage)
                            ,item.Ten
                            ,item.Mota
                            ,item.Ngaytao.ToString("dd/MM/yy")
                            ,item.NguoiTao
                            ,item.Active.ToString()

                        }));
                    }
                    grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PagerGet.TotalPages.ToString(), PagerGet.Total.ToString(), ListRowVideo);
                    sb.Append(JavaScriptConvert.SerializeObject(grid));
                    break;
                    #endregion
                case "saveVideo":
                    #region lưu dữ liệu
                    Thuvien ItemSaveVideo = new Thuvien();
                    if (!string.IsNullOrEmpty(_tv_id))
                    {
                        ItemSaveVideo = ThuvienDal.SelectById(Convert.ToInt32(_tv_id));
                    }

                    ItemSaveVideo.Ngaytao = DateTime.Now;
                    ItemSaveVideo.Ten = _tv_ten;
                    ItemSaveVideo.GH_ID = int.Parse(_tv_gh_id);
                    ItemSaveVideo.Mota = string.IsNullOrEmpty(_tv_mota) ? "" : _tv_mota;
                    ItemSaveVideo.Active = Convert.ToBoolean(_tv_active);
                    ItemSaveVideo.UrlImage = _tv_UrlImage;
                    ItemSaveVideo.Url = _tv_Url;
                    ItemSaveVideo.Thutu = Convert.ToInt16(_tv_thutu);
                    ItemSaveVideo.Loai = 1;
                    ItemSaveVideo.Keyword = "";
                    ItemSaveVideo.CateID = 0;
                    ItemSaveVideo.NguoiTao = Security.Username;

                    // ItemSave.PID = Convert.ToInt32(_PID);

                    if (!string.IsNullOrEmpty(_tv_id))
                    {
                        ItemSaveVideo = ThuvienDal.Update(ItemSaveVideo);
                    }
                    else
                    {
                        ItemSaveVideo.RowId = Guid.NewGuid();
                        ItemSaveVideo = ThuvienDal.Insert(ItemSaveVideo);
                    }
                    sb.Append("1");
                    break;
                    #endregion
                case "delVideo":
                    #region xóa
                    if (!string.IsNullOrEmpty(_tv_id))
                    {
                        char[] step = { ',' };
                        string[] arrID = _tv_id.Split(step);
                        for (int j = 0; j < arrID.Length; j++)
                        {
                            if (arrID[j] != "")
                            {
                                Thuvien o = new Thuvien();
                                o = ThuvienDal.SelectById(Convert.ToInt32(arrID[j]));
                                try
                                {
                                    System.IO.File.Delete(Server.MapPath("~/up/v/" + o.UrlImage));
                                    System.IO.File.Delete(Server.MapPath("~/up/v/" + o.Url));
                                }
                                catch { }
                                ThuvienDal.DeleteById(Convert.ToInt32(arrID[j]));
                            }
                        }
                    }
                    break;
                    #endregion
                case "duyetVideo":
                    #region Duyệt
                    if (!string.IsNullOrEmpty(_tv_id))
                    {
                        char[] step = { ',' };
                        string[] arrID = _tv_id.Split(step);
                        for (int j = 0; j < arrID.Length; j++)
                        {
                            if (arrID[j] != "")
                            {
                                Thuvien o = new Thuvien();
                                o = ThuvienDal.SelectById(Convert.ToInt32(arrID[j]));
                                o.Active = true;
                                ThuvienDal.Update(o);
                            }
                        }
                    }
                    break;
                    #endregion
                case "dungVideo":
                    #region Dừng
                    if (!string.IsNullOrEmpty(_tv_id))
                    {
                        char[] step = { ',' };
                        string[] arrID = _tv_id.Split(step);
                        for (int j = 0; j < arrID.Length; j++)
                        {
                            if (arrID[j] != "")
                            {
                                Thuvien o = new Thuvien();
                                o = ThuvienDal.SelectById(Convert.ToInt32(arrID[j]));
                                o.Active = false;
                                ThuvienDal.Update(o);
                            }
                        }
                    }
                    break;
                    #endregion
                case "editVideo":
                    #region chỉnh sửa
                    if (!string.IsNullOrEmpty(_tv_id))
                    {
                        sb.Append("(" + JavaScriptConvert.SerializeObject(ThuvienDal.SelectById(Convert.ToInt32(_tv_id))) + ")");
                    }
                    break;
                    #endregion
                case "getFlash":
                    #region lấy danh sách
                    if (string.IsNullOrEmpty(jgRows)) jgRows = "5";
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "Flh_ID";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "asc";
                    Pager<Flash> PagerGetFlash = FlashDal.pagerNormal("", false, jgrsidx + " " + jgrsord, _q, _flh_gh_id, Request["rows"]);
                    List<jgridRow> ListRowFlash = new List<jgridRow>();
                    foreach (Flash item in PagerGetFlash.List)
                    {
                        if (item.PathImage != "")
                        {
                            ListRowFlash.Add(new jgridRow(item.ID.ToString(), new string[]{
                            item.ID.ToString()
                            ,(item.Thutu.ToString())
                            ,string.Format("<img class=\"adm-pro-icon\" src=\"../up/i/{0}\" />", string.IsNullOrEmpty(item.PathImage) ? "no-image.png" :item.PathImage)
                            ,item.Ten
                            ,item.Ngaytao.ToString("dd/MM/yyyy")
                            ,item.NguoiTao
                            ,item.Active.ToString()
                            }));
                        }
                        else
                        {
                            ListRowFlash.Add(new jgridRow(item.ID.ToString(), new string[]{
                            item.ID.ToString()
                            ,(item.Thutu.ToString())
                            ,string.Format("<embed class=\"adm-pro-icon\" src=\"../up/v/{0}\" />", string.IsNullOrEmpty(item.PathFlash) ? "no-image.png" :item.PathFlash)
                            ,item.Ten
                            ,item.Ngaytao.ToString("dd/MM/yyyy")
                            ,item.NguoiTao
                            ,item.Active.ToString()
                            }));
                        }
                    }
                    grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PagerGetFlash.TotalPages.ToString(), PagerGetFlash.Total.ToString(), ListRowFlash);
                    sb.Append(JavaScriptConvert.SerializeObject(grid));
                    break;
                    #endregion
                case "saveFlash":
                    #region lưu dữ liệu
                    Flash ItemSaveFlash = new Flash();
                    if (!string.IsNullOrEmpty(_flh_id))
                    {
                        ItemSaveFlash = FlashDal.SelectById(Convert.ToInt32(_flh_id));
                    }

                    ItemSaveFlash.Ngaytao = DateTime.Now;
                    ItemSaveFlash.Ten = _flh_ten;
                    ItemSaveFlash.GH_ID = int.Parse(_flh_gh_id);
                    ItemSaveFlash.Mota = string.IsNullOrEmpty(_flh_mota) ? "" : _flh_mota;
                    ItemSaveFlash.Active = Convert.ToBoolean(_flh_active);
                    if (_flh_pathimg !=null) {
                        ItemSaveFlash.PathImage = _flh_pathimg;
                        ItemSaveFlash.PathFlash = "";
                    }
                    if (_flh_pathflash !=null)
                    {
                        ItemSaveFlash.PathImage = "";
                        ItemSaveFlash.PathFlash = _flh_pathflash;
                    }
                    ItemSaveFlash.Thutu = Convert.ToInt16(_flh_thutu);
                    ItemSaveFlash.NguoiTao = Security.Username;

                    // ItemSave.PID = Convert.ToInt32(_PID);

                    if (!string.IsNullOrEmpty(_flh_id))
                    {
                        ItemSaveFlash = FlashDal.Update(ItemSaveFlash);
                    }
                    else
                    {
                        ItemSaveFlash.RowId = Guid.NewGuid();
                        ItemSaveFlash = FlashDal.Insert(ItemSaveFlash);
                    }
                    sb.Append("1");
                    break;
                    #endregion
                case "delFlash":
                    #region xóa
                    FlashDal.DeleteById(Convert.ToInt32(_flh_id));
                    break;
                    #endregion
                case "duyetFlash":
                    #region Duyệt

                    Flash duyetflash = new Flash();
                    duyetflash = FlashDal.SelectById(Convert.ToInt32(_flh_id));
                    duyetflash.Active = true;
                    FlashDal.Update(duyetflash);
                    break;
                    #endregion
                case "dungFlash":
                    #region Dừng

                    Flash dungflash = new Flash();
                    dungflash = FlashDal.SelectById(Convert.ToInt32(_flh_id));
                    dungflash.Active = false;
                    FlashDal.Update(dungflash);
                    break;
                    #endregion
                case "editFlash":
                    #region chỉnh sửa
                    if (!string.IsNullOrEmpty(_flh_id))
                    {
                        sb.Append("(" + JavaScriptConvert.SerializeObject(FlashDal.SelectById(Convert.ToInt32(_flh_id))) + ")");
                    }
                    break;
                    #endregion
                case "getHinhAnh":
                    #region lấy danh sách
                    if (string.IsNullOrEmpty(jgRows)) jgRows = "5";
                    if (string.IsNullOrEmpty(jgrsidx)) jgrsidx = "HA_ID";
                    if (string.IsNullOrEmpty(jgrsord)) jgrsord = "asc";
                    Pager<HinhAnh> PagerGetHA = HinhAnhDal.pagerNormal("", false, jgrsidx + " " + jgrsord, _q, _ha_gh_id, Request["rows"]);
                    List<jgridRow> ListRowHA = new List<jgridRow>();
                    foreach (HinhAnh item in PagerGetHA.List)
                    {
                        ListRowHA.Add(new jgridRow(item.ID.ToString(), new string[]{
                            item.ID.ToString()
                            ,string.Format("<img class=\"adm-pro-icon\" src=\"../up/i/{0}\" />", string.IsNullOrEmpty(item.PathImage) ? "no-image.png" :item.PathImage)
                            ,item.Ten
                            ,item.Link
                            ,item.Ngaytao.ToString("dd/MM/yyyy")
                            ,item.NguoiTao
                            ,item.Active.ToString()

                        }));
                    }
                    grid = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage, PagerGetHA.TotalPages.ToString(), PagerGetHA.Total.ToString(), ListRowHA);
                    sb.Append(JavaScriptConvert.SerializeObject(grid));
                    break;
                    #endregion
                case "saveHinhAnh":
                    #region lưu dữ liệu
                    HinhAnh ItemSaveAnh = new HinhAnh();
                    if (!string.IsNullOrEmpty(_ha_id))
                    {
                        ItemSaveAnh = HinhAnhDal.SelectById(Convert.ToInt32(_ha_id));
                    }
                    ItemSaveAnh.Ngaytao = DateTime.Now;
                    ItemSaveAnh.Ten = _ha_ten;
                    ItemSaveAnh.GH_ID = int.Parse(_ha_gh_id);
                    ItemSaveAnh.Mota = string.IsNullOrEmpty(_ha_mota) ? "" : _ha_mota;
                    ItemSaveAnh.Active = Convert.ToBoolean(_ha_active);
                    ItemSaveAnh.PathImage = _ha_pathimg;
                    ItemSaveAnh.Link = _ha_link;
                    ItemSaveAnh.NguoiTao = Security.Username;
                    if (!string.IsNullOrEmpty(_ha_id))
                    {
                        ItemSaveAnh = HinhAnhDal.Update(ItemSaveAnh);
                    }
                    else
                    {
                        ItemSaveAnh.RowId = Guid.NewGuid();
                        ItemSaveAnh = HinhAnhDal.Insert(ItemSaveAnh);
                    }
                    sb.Append("1");
                    break;
                    #endregion
                case "editHinhAnh":
                    #region chỉnh sửa
                    if (!string.IsNullOrEmpty(_ha_id))
                    {
                        sb.Append("(" + JavaScriptConvert.SerializeObject(HinhAnhDal.SelectById(Convert.ToInt32(_ha_id))) + ")");
                    }
                    break;
                    #endregion
                case "delHinhAnh":
                    #region xóa
                    if (!string.IsNullOrEmpty(_ha_id))
                    {
                        char[] step = { ',' };
                        string[] arrID = _ha_id.Split(step);
                        for (int j = 0; j < arrID.Length; j++)
                        {
                            if (arrID[j] != "")
                            {
                                HinhAnh o = new HinhAnh();
                                o = HinhAnhDal.SelectById(Convert.ToInt32(arrID[j]));
                                try
                                {
                                    System.IO.File.Delete(Server.MapPath("~/up/i/" + o.PathImage));
                                }
                                catch { }
                                HinhAnhDal.DeleteById(Convert.ToInt32(arrID[j]));
                            }
                        }
                    }
                    break;
                    #endregion
                case "duyetHinhAnh":
                    #region Duyệt
                    if (!string.IsNullOrEmpty(_ha_id))
                    {
                        char[] step = { ',' };
                        string[] arrID = _ha_id.Split(step);
                        for (int j = 0; j < arrID.Length; j++)
                        {
                            if (arrID[j] != "")
                            {
                                HinhAnh o = new HinhAnh();
                                o = HinhAnhDal.SelectById(Convert.ToInt32(arrID[j]));
                                o.Active = true;
                                HinhAnhDal.Update(o);
                            }
                        }
                    }
                    break;
                    #endregion
                case "dungHinhAnh":
                    #region Dừng
                    if (!string.IsNullOrEmpty(_ha_id))
                    {
                        char[] step = { ',' };
                        string[] arrID = _ha_id.Split(step);
                        for (int j = 0; j < arrID.Length; j++)
                        {
                            if (arrID[j] != "")
                            {
                                HinhAnh o = new HinhAnh();
                                o = HinhAnhDal.SelectById(Convert.ToInt32(arrID[j]));
                                o.Active = false;
                                HinhAnhDal.Update(o);
                            }
                        }
                    }
                    break;
                    #endregion
                case "scpt":
                    #region Nạp js
                    sb.AppendFormat(@"{0}"
                        , cs.GetWebResourceUrl(typeof(doanhNghiep), "cnn.plugin.doanhNghiep.doanhNghiep.js"));
                    //sb.AppendFormat(@"{0}"
                    //    , cs.GetWebResourceUrl(typeof(Class1), "cnn.plugin.QuanLySanPham.Publish.js"));
                    break;
                    #endregion

                default:
                    #region Nap
                    FunctionCollection ListFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId); //Kiem tra quyen

                    sb.Append(@"<div id =""DoanhNghiepChuaDuyet-Main-NewDlg"">
                    </div>
                    ");
                    sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                        , cs.GetWebResourceUrl(typeof(doanhNghiep), "cnn.plugin.doanhNghiep.doanhNghiep.js")
                        , "{doanhNghiepFn.loadForm();}");
                    sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(ListFn));
                    break;
                    #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }