예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();

        string imgSaveLoc    = Server.MapPath("~/lib/up/i/");
        string imgSaveTintuc = Server.MapPath("~/lib/up/tintuc/");
        string imgTemp       = Server.MapPath("~/lib/up/temp/");
        string docTemp       = Server.MapPath("~/lib/up/d/");
        bool   loggedIn      = Security.IsAuthenticated();

        insertLog("0", Security.Username, Request.UserHostAddress, Request.Url.PathAndQuery);
        switch (act)
        {
        case "loadPlug":
            if (rqPlug != null)
            {
                sb.Append(PlugHelper.RenderHtml(rqPlug));
            }
            rendertext(sb);
            break;

        case "upload":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(730, 600);
                    img.Save(imgSaveLoc + imgten + "730x600" + img.Ext);
                    img.Crop(420, 280);
                    img.Save(imgSaveLoc + imgten + "420x280" + img.Ext);
                    img.Crop(130, 100);
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadTintuc":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(730, 600);
                    img.Save(imgSaveTintuc + imgten + "730x600" + img.Ext);
                    img.Crop(420, 280);
                    img.Save(imgSaveTintuc + imgten + "420x280" + img.Ext);
                    img.Crop(130, 100);
                    img.Save(imgSaveTintuc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadFull":
            #region upload ảnh
            if (Security.IsAuthenticated())
            {
                if (Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
            }
            break;

            #endregion
        case "uploadfileDkLuong":
            #region upload tài liệu
            if (!loggedIn)
            {
                rendertext("403");
            }
            if (Request.Files[0] != null)
            {
                string foldername = Guid.NewGuid().ToString().Replace("-", "");
                string filename   = Path.GetFileNameWithoutExtension(Request.Files[0].FileName);
                string fileType   = Path.GetExtension(Request.Files[0].FileName);
                Directory.CreateDirectory(docTemp + foldername);
                Request.Files[0].SaveAs(docTemp + foldername + "/" + filename + fileType);
                Files item = new Files();
                item.Download = 0;
                item.MimeType = fileType;
                item.NgayTao  = DateTime.Now;
                item.NguoiTao = Security.Username;
                item.Path     = filename;
                item.PID      = Guid.NewGuid();
                item.RowId    = Guid.NewGuid();
                item.Size     = Request.Files[0].ContentLength;
                item.Ten      = filename;
                item.ThuMuc   = foldername;
                item.VB_ID    = 0;
                item          = FilesDal.Insert(item);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "download":
            string _F_ID = Request["ID"];
            if (!string.IsNullOrEmpty(_F_ID))
            {
                Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                Response.Buffer = true;
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment; filename=\"" + item.Ten + item.MimeType + "\"");
                Response.ContentType = "octet/stream";
                //Response.ContentType = "application/ms-word";
                Response.WriteFile(Server.MapPath("~/lib/up/d/") + item.ThuMuc + "/" + item.Path + item.MimeType);
            }
            break;

        case "loadPlugDirect":
            if (!string.IsNullOrEmpty(rqPlug))
            {
                string _IPlugType = rqPlug;
                Type   type       = Type.GetType(_IPlugType);
                IPlug  _IPlug     = (IPlug)(Activator.CreateInstance(type));
                _IPlug.ImportPlugin();
                Page        pageHolder = new Page();
                UserControl uc         = (UserControl)(_IPlug);
                this.Controls.Add(uc);
            }
            break;

        case "uploadvideo":

            break;

        default:
            string d = "12/9/2010";
            //DateTime da = Convert.ToDateTime(d, new System.Globalization.CultureInfo("vi-Vn"));
            //Response.Write(da.Month.ToString());
            Response.Write(maHoa.EncryptString("111", "phatcd"));
            break;
        }
    }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sb              = new StringBuilder();
            string        act             = context.Request["act"];
            string        rqPlug          = context.Request["rqPlug"];
            string        imgSaveLoc      = context.Server.MapPath("~/lib/up/i/");
            string        imgTemp         = context.Server.MapPath("~/lib/up/temp/");
            string        docTemp         = context.Server.MapPath("~/lib/up/d/");
            string        imgSaveTintuc   = context.Server.MapPath("~/lib/up/tintuc/");
            string        imgSaveSanPham  = context.Server.MapPath("~/lib/up/sanpham/");
            string        imgSaveQuangCao = context.Server.MapPath("~/lib/up/quangcao/");
            string        imgSaveKTNN     = context.Server.MapPath("~/lib/up/KTNN/");

            string _height   = context.Request["height"];
            string _width    = context.Request["width"];
            string _PRowIdSP = context.Request["PRowIdSP"];

            switch (act)
            {
            case "loadPlug":
                #region loadPlug: nap plug
                if (rqPlug != null)
                {
                    sb.Append(PlugHelper.RenderHtml(rqPlug));
                }
                rendertext(sb);
                break;

                #endregion
            case "upload":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, imgten);
                    context.Request.Files[0].SaveAs(imgSaveLoc + imgten + "full" + img.Ext);

                    img.Crop(420, 560);
                    img.Save(imgSaveLoc + imgten + "420x560" + img.Ext);

                    img.Crop(240, 180);
                    img.Save(imgSaveLoc + imgten + "240x180" + img.Ext);

                    img.Crop(100, 100);
                    img.Save(imgSaveLoc + imgten + "100x100" + img.Ext);

                    img.Crop(50, 50);
                    img.Save(imgSaveLoc + imgten + img.Ext);

                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadQuangCao":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveQuangCao + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveQuangCao + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveQuangCao + imgten + "source" + img.Ext);
                    img.Crop(int.Parse(_width), int.Parse(_height));
                    img.Save(imgSaveQuangCao + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadSanPham":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveSanPham + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveSanPham + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Crop(400, 400);
                    img.Save(imgSaveSanPham + imgten + "400x400" + img.Ext);
                    img.Crop(400, 300);
                    img.Save(imgSaveSanPham + imgten + "400x300" + img.Ext);
                    img.Crop(200, 200);
                    img.Save(imgSaveSanPham + imgten + "200x200" + img.Ext);
                    img.Crop(90, 90);
                    img.Save(imgSaveSanPham + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }

                break;

                #endregion
            case "uploadTintuc":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveTintuc + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveTintuc + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        context.Request.Files[0].SaveAs(imgSaveTintuc + imgten + "full" + img.Ext);
                        img.Crop(180, 120);
                        img.Save(imgSaveTintuc + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadKTNN":
                #region upload ?nh
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten = Guid.NewGuid().ToString();
                        if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                        {
                            try
                            {
                                imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                                if (File.Exists(imgSaveKTNN + context.Request["oldFile"]))
                                {
                                    File.Delete(imgSaveKTNN + context.Request["oldFile"]);
                                }
                            }
                            finally
                            {
                            }
                        }
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(730, 600);
                        img.Save(imgSaveKTNN + imgten + "730x600" + img.Ext);
                        img.Crop(420, 280);
                        img.Save(imgSaveKTNN + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveKTNN + imgten + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }
                break;

                #endregion
            case "uploadFlash":
                #region upload flash
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".swf")
                    {
                        string flash = Guid.NewGuid().ToString();

                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + flash + Path.GetExtension(context.Request.Files[0].FileName));
                        rendertext(flash + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                    else
                    {
                        ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                        img.Crop(420, 280);
                        img.Save(imgSaveLoc + imgten + "420x280" + img.Ext);
                        img.Crop(130, 100);
                        img.Save(imgSaveLoc + imgten + img.Ext);
                        img.Crop(370, 90);
                        img.Save(imgSaveLoc + imgten + "370x90" + img.Ext);
                        rendertext(imgten + img.Ext);
                    }
                }

                break;

                #endregion
            case "uploadFull":
                #region upload ?nh
                if (context.Request.Files[0] != null)
                {
                    string imgten = Guid.NewGuid().ToString();
                    if (!string.IsNullOrEmpty(context.Request["oldFile"]))
                    {
                        try
                        {
                            imgten = Path.GetFileNameWithoutExtension(context.Request["oldFile"]);
                            if (File.Exists(imgSaveLoc + context.Request["oldFile"]))
                            {
                                File.Delete(imgSaveLoc + context.Request["oldFile"]);
                            }
                        }
                        finally
                        {
                        }
                    }
                    ImageProcess img = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    img.Save(imgSaveLoc + imgten + img.Ext);
                    rendertext(imgten + img.Ext);
                }
                break;

                #endregion
            case "uploadfileDkLuong":
                #region upload tài li?u
                //if (!loggedIn) rendertext("403");
                if (context.Request.Files[0] != null)
                {
                    string foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string filename   = Path.GetFileNameWithoutExtension(context.Request.Files[0].FileName);
                    string fileType   = Path.GetExtension(context.Request.Files[0].FileName);
                    Directory.CreateDirectory(docTemp + foldername);
                    context.Request.Files[0].SaveAs(docTemp + foldername + "/" + filename + fileType);
                    //context.Request.Files[0].SaveAs(docTemp +  filename + fileType);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = fileType;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = filename;
                    item.PID      = Guid.NewGuid();
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = filename;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(item.ID.ToString());
                }
                break;

                #endregion
            case "download":
                string _F_ID = context.Request["ID"];
                if (!string.IsNullOrEmpty(_F_ID))
                {
                    Files item = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                    context.Response.Buffer = true;
                    context.Response.Clear();
                    context.Response.AddHeader("content-disposition", "attachment; filename=\"" + item.Ten + item.MimeType + "\"");
                    context.Response.ContentType = "octet/stream";
                    //Response.ContentType = "application/ms-word";
                    context.Response.WriteFile(context.Server.MapPath("~/lib/up/d/") + item.ThuMuc + "/" + item.Path + item.MimeType);
                }
                break;

            case "uploadvideo":
                if (Security.IsAuthenticated())
                {
                    if (context.Request.Files[0] != null)
                    {
                        string imgten         = Guid.NewGuid().ToString();
                        string strVideoRender = "";
                        context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        string _hinhanh = "";
                        string fWmv     = "";
                        if (Path.GetExtension(context.Request.Files[0].FileName).ToLower() == ".flv")
                        {
                            fWmv = WMV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");
                            context.Request.Files[0].SaveAs(context.Server.MapPath("~/lib/up/v/") + fWmv);
                            _hinhanh = CreatImg(context, fWmv, imgten + Path.GetExtension(context.Request.Files[0].FileName));
                            System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + fWmv);
                        }
                        else
                        {
                            fWmv = FLV_encode(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), "320", "240", "64", "44100");

                            fWmv     = context.Request.Files[0].FileName;
                            _hinhanh = CreatImg(context, imgten + Path.GetExtension(context.Request.Files[0].FileName), imgten + Path.GetExtension(context.Request.Files[0].FileName));
                        }
                        rendertext(_hinhanh + ";" + imgten + Path.GetExtension(context.Request.Files[0].FileName));
                    }
                }

                break;

            case "DelOldFlash":
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/v/") + Path.GetExtension(context.Request.Files[0].FileName));
                System.IO.File.Delete(context.Server.MapPath("~/lib/up/i/") + Path.GetExtension(context.Request.Files[0].FileName));
                break;

            case "MultiuploadImg":
                #region UploadAnh
                if (context.Request.Files[0] != null)
                {
                    ImageProcess img        = new ImageProcess(context.Request.Files[0].InputStream, Guid.NewGuid().ToString());
                    string       foldername = Guid.NewGuid().ToString().Replace("-", "");
                    string       imgten     = Guid.NewGuid().ToString();
                    Directory.CreateDirectory(imgSaveSanPham + foldername);

                    context.Request.Files[0].SaveAs(imgSaveSanPham + foldername + "/" + imgten + "full" + img.Ext);
                    img.Crop(400, 400);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + "400x400" + img.Ext);
                    img.Crop(75, 75);

                    img.Save(imgSaveSanPham + foldername + "/" + imgten + img.Ext);
                    Files item = new Files();
                    item.Download = 0;
                    item.MimeType = img.Ext;
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.Path     = imgten + img.Ext;
                    item.PID      = new Guid(_PRowIdSP);
                    item.RowId    = Guid.NewGuid();
                    item.Size     = context.Request.Files[0].ContentLength;
                    item.Ten      = imgten;
                    item.ThuMuc   = foldername;
                    item.VB_ID    = 0;
                    item          = FilesDal.Insert(item);
                    rendertext(sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item)));
                }
                break;

                #endregion
            case "loadPlugDirect":
                if (!string.IsNullOrEmpty(rqPlug))
                {
                    string _IPlugType = rqPlug;
                    Type   type       = Type.GetType(_IPlugType);
                    IPlug  _IPlug     = (IPlug)(Activator.CreateInstance(type));
                    _IPlug.ImportPlugin();
                    UserControl uc   = (UserControl)(_IPlug);
                    Page        page = new Page();
                    page.EnableViewState = false;
                    HtmlForm form = new HtmlForm();
                    form.ID = "__t";
                    page.Controls.Add(form);
                    form.Controls.Add(uc);
                    StringWriter tw = new StringWriter();
                    HttpContext.Current.Server.Execute(page, tw, true);
                }
                break;

            case "capcha":
                #region capcha
                string _capchaCode = CaptchaImage.GenerateRandomCode(CaptchaType.AlphaNumeric, 3);
                context.Session["capcha"] = _capchaCode;
                CaptchaImage c = new CaptchaImage(_capchaCode, 200, 50, "Tahoma", Color.White, Color.Orange);
                context.Response.ClearContent();
                context.Response.ContentType = "image/jpeg";
                MemoryStream ms = new MemoryStream();
                c.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                context.Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length));
                ms.Close();
                context.Response.End();
                break;

                #endregion
            default:
                #region macdinh
                context.Response.Write(DateTime.Now.ToString("hh:mm"));
                break;
                #endregion
            }
        }
예제 #3
0
        protected override void Render(HtmlTextWriter writer)
        {
            var sb = new StringBuilder();
            var cs = this.Page.ClientScript;

            #region Tham số
            var             ID           = Request["ID"];
            var             DM_ID        = Request["DM_ID"];
            var             GH_ID        = Request["GH_ID"];
            var             Lang         = Request["Lang"];
            var             LangBased_ID = Request["LangBased_ID"];
            var             LangBased    = Request["LangBased"];
            var             Alias        = Request["Alias"];
            var             Ten          = Request["Ten"];
            var             Ma           = Request["Ma"];
            var             Keywords     = Request["Keywords"];
            var             Description  = Request["Description"];
            var             MoTa         = Request["MoTa"];
            var             NoiDung      = Request["NoiDung"];
            var             GNY          = Request["GNY"];
            var             GiaNhap      = Request["GiaNhap"];
            var             DonVi_ID     = Request["DonVi_ID"];
            var             SoLuong      = Request["SoLuong"];
            var             RowId        = Request["RowId"];
            var             NgayTao      = Request["NgayTao"];
            var             NguoiTao     = Request["NguoiTao"];
            var             NgayCapNhat  = Request["NgayCapNhat"];
            var             NguoiCapNhat = Request["NguoiCapNhat"];
            var             Anh          = Request["Anh"];
            var             Publish      = Request["Publish"];
            var             Active       = Request["Active"];
            var             Home         = Request["Home"];
            var             Hot1         = Request["Hot1"];
            var             Hot2         = Request["Hot2"];
            var             Hot3         = Request["Hot3"];
            var             Hot4         = Request["Hot4"];
            var             HetHang      = Request["HetHang"];
            var             TonDinhMuc   = Request["TonDinhMuc"];
            var             Draff        = Request["Draff"];
            var             _q           = Request["q"];
            var             draff        = Request["draff"];
            var             Loai         = Request["Loai"];
            var             Rep_Ten      = Request["Rep_Ten"];
            var             Rep_Ngay     = Request["Rep_Ngay"];
            var             _F_ID        = Request["F_ID"];
            List <jgridRow> ListRow      = new List <jgridRow>();

            //List<DanhMuc> ListDanhMucBG = new List<DanhMuc>();
            #endregion
            switch (subAct)
            {
            case "get":
                #region lấy dữ liệu cho grid
                var pagerGet = HangHoaDal.ByDm("", false, jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), DM_ID);
                foreach (HangHoa item in pagerGet.List)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                        item.ID.ToString()
                        , item.DM_Ten
                        , item.Ma
                        , item.Ten
                        , Lib.TienVietNam(item.GiaNhap)
                        , Lib.TienVietNam(item.GNY)
                        , item.SoLuong.ToString()
                        , item.DonVi_Ten
                        , string.Format("{0:dd/MM/yy}", item.NgayCapNhat)
                    }));
                }
                jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                                            , pagerGet.TotalPages.ToString()
                                            , pagerGet.Total.ToString()
                                            , ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm));
                break;

                #endregion
            case "del":
                #region xóa
                if (!string.IsNullOrEmpty(ID))
                {
                    HangHoaDal.DeleteByMultiId(ID);
                }
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(ID))
                {
                    var hhitem = HangHoaDal.SelectById(new Guid(ID));
                    hhitem.ListFiles = FilesDal.SelectByPRowId(hhitem.ID);
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(hhitem));
                }
                break;

                #endregion
            case "draff":
                #region draff
                sb.Append(Guid.NewGuid().ToString());
                break;

                #endregion
            case "autoCompleteByQ":
                #region lấy dữ liệu cho grid
                var pagerByQ = HangHoaDal.ByDm("", false, "HH_NgayTao asc", _q, 10, string.Empty);
                sb.Append(JavaScriptConvert.SerializeObject(pagerByQ.List));
                break;

                #endregion
            case "save":
                #region save
                if (Security.IsAuthenticated())
                {
                    var item = draff == "1" ? new HangHoa() : HangHoaDal.SelectById(new Guid(ID));
                    item.DM_ID        = new Guid(DM_ID);
                    item.Ten          = Ten;
                    item.Ma           = Ma;
                    item.Keywords     = Keywords;
                    item.MoTa         = MoTa;
                    item.NoiDung      = NoiDung;
                    item.GNY          = Convert.ToDouble(GNY);
                    item.GiaNhap      = Convert.ToDouble(GiaNhap);
                    item.DonVi_ID     = new Guid(DonVi_ID);
                    item.SoLuong      = Convert.ToDouble(SoLuong);
                    item.Anh          = Anh;
                    item.HetHang      = Convert.ToBoolean(HetHang);
                    item.TonDinhMuc   = Convert.ToDouble(TonDinhMuc);
                    item.NguoiCapNhat = Security.Username;
                    item.NgayCapNhat  = DateTime.Now;
                    if (draff == "1")
                    {
                        item.ID       = new Guid(ID);
                        item.NgayTao  = DateTime.Now;
                        item.NguoiTao = Security.Username;
                        item.RowId    = Guid.NewGuid();
                        item          = HangHoaDal.Insert(item);
                    }
                    else
                    {
                        item = HangHoaDal.Update(item);
                    }
                    sb.Append("1");
                }
                break;

                #endregion
            case "DeleteDoc":
                #region Xóa tài liệu đính kèm
                if (!string.IsNullOrEmpty(_F_ID))
                {
                    Files  item   = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                    string _files = Server.MapPath("~/lib/up/sanpham/") + item.ThuMuc + @"\";
                    string _file1 = _files + @"\" + item.Ten + item.MimeType;
                    string _file2 = _files + @"\" + item.Ten + "400x400" + item.MimeType;
                    if (Directory.Exists(_files))
                    {
                        File.Delete(_file1);
                        File.Delete(_file2);
                        Directory.Delete(_files);
                    }
                    FilesDal.DeleteById(item.ID);
                }
                break;

                #endregion
            case "reports":
                #region bao cao
                var pagerGetReport = HangHoaDal.ByDm("", false, jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), DM_ID);

                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.hangHoaMgr.JScript1.js"));
                //sb.AppendFormat(@"{0}"
                //    , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.hangHoaMgr.Publish.js"));
                break;

                #endregion
            default:
                #region nạp
                var listFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "mdl.htm"));
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.hangHoaMgr.JScript1.js")
                                , "{hangHoaMgrFn.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(listFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }