Exemplo n.º 1
0
 protected void btedit_ServerClick(object sender, EventArgs e)
 {
     try
     {
         string title = txttitle.Value.Trim();
         string sum   = txtsumcontent.Value.Trim();
         content = Request.Form["txtContent"].ToString();
         string source  = txtsource.Value.Trim();
         string link    = txtlink.Value.Trim();
         int    idgroup = int.Parse(slGroup.Value);
         string ishow   = "0";
         if (checkshow.Checked)
         {
             ishow = "1";
         }
         if (title.Length == 0)
         {
             diverror.Visible   = true;
             diverror.InnerHtml = "<div class='diverror'>Xin bạn hãy nhập tiêu đề tin</div>";
             return;
         }
         else if (sum.Length == 0)
         {
             diverror.Visible   = true;
             diverror.InnerHtml = "<div class='diverror'>Xin hãy nhập mô tả ngắn gọn tin tức</div>";
             return;
         }
         else
         {
             DataSet dsArticle = Articles.AdminArticleTestExsit(id, title);
             if (dsArticle.Tables.Count > 0)
             {
                 if (dsArticle.Tables[0].Rows.Count > 0)
                 {
                     Boolean isUpdate = false;
                     if (dsArticle.Tables[1].Rows.Count > 0)
                     {
                         if (dsArticle.Tables[1].Rows[0]["id"].ToString() == id.ToString())
                         {
                             //Update:
                             isUpdate = true;
                         }
                         else
                         {
                             diverror.Visible   = true;
                             diverror.InnerHtml = "<div class='diverror'>Tiêu đề tin đã tồn tại, xin hãy nhập tiêu đề khác</div>";
                             return;
                         }
                     }
                     else
                     {
                         //Update:
                         isUpdate = true;
                     }
                     string   nameImage = "";
                     DateTime time      = new DateTime();
                     time = DateTime.Now;
                     CvalidateImageForPost manageImage = new CvalidateImageForPost();
                     nameImage = dsArticle.Tables[0].Rows[0]["urlImage"].ToString();
                     if (ImageArticle.PostedFile.FileName.Length > 0)
                     {
                         nameImage = "article_image_" + id + "." + manageImage.GetExtension(ImageArticle.PostedFile.FileName);
                     }
                     if (isUpdate)
                     {
                         if (Articles.AdminArticleUpdate(id, idgroup, title, sum, content, nameImage, time, source, link, ishow))
                         {
                             diverror.Visible   = true;
                             diverror.InnerHtml = "<div class='diverror'>Tin tức đã được chỉnh sửa</div>";
                             //UpdateArticle:
                             if (ImageArticle.PostedFile.FileName.Length > 0)
                             {
                                 string path = Server.MapPath("../image/img_article/");
                                 if (dsArticle.Tables[0].Rows[0]["urlImage"].ToString().Length > 0)
                                 {
                                     manageImage.DeleteFile(path + dsArticle.Tables[0].Rows[0]["urlImage"].ToString().Length);
                                 }
                                 if (manageImage.TestMaxSizeImage(ImageArticle, 71680))
                                 {
                                     diverror.InnerHtml += "<div class='diverror'>Ảnh không quá 70 KB</div>";
                                 }
                                 else
                                 {
                                     manageImage.UploadFile_server(ImageArticle, path + nameImage);
                                 }
                             }
                             return;
                         }
                         else
                         {
                             diverror.Visible   = true;
                             diverror.InnerHtml = "<div class='diverror'>Lỗi kết nối, không thể thêm mới tin tức</div>";
                             return;
                         }
                     }
                 }
                 else
                 {
                     Response.Redirect("AdminWebsite.aspx?menu=grouparticle");
                 }
             }
             else
             {
                 Response.Redirect("AdminWebsite.aspx?menu=grouparticle");
             }
         }
     }
     catch
     { }
 }
    protected string ButtonUpload_UploadClick(object sender, WebControls.UploadButtonEventArgs e)
    {
        string message = "";

        try
        {
            if (Session["SSIdProUpload"] == null)
            {
                message = "Xin bạn hãy chọn sản phẩm muốn upload ảnh.";
                return(message);
            }
            else
            {
                string   strIdAndName            = Session["SSIdProUpload"].ToString();
                string[] arrvalue                = strIdAndName.Split(',');
                CvalidateImageForPost imgProcess = new CvalidateImageForPost();
                FileUpload            file       = e.FileUploadControl;
                string file_name = file.PostedFile.FileName;
                if (file_name.Length == 0)
                {
                    message = "Xin bạn hãy chọn file ảnh";
                    return(message);
                }
                else
                {
                    if (!imgProcess.TestTypeFile(file))
                    {
                        message = "File Không hợp lệ";
                        return(message);
                    }
                    else if (imgProcess.TestMaxSizeImage(file, 30720))
                    {
                        message = "Kích thước ảnh không quá 30 KB";
                        return(message);
                    }
                    else
                    {
                        string _path   = Server.MapPath("../image/img_pro/");
                        string namepro = "_";
                        if (arrvalue.Length == 3)
                        {
                            namepro = arrvalue[2];
                        }
                        string  strgetTime = new CGetDataCommon().GetStrMonthDayYearSecondMinuteHour();
                        string  nameNew    = "pro_" + arrvalue[0] + "_" + namepro + "_" + strgetTime + "." + imgProcess.GetExtension(file_name);
                        Boolean isUpload   = imgProcess.UploadFile(file, _path + nameNew);
                        if (isUpload)
                        {
                            ProductSystem ManagerPro = new ProductSystem();
                            Boolean       isUpdate   = ManagerPro.ProductUpdateImage(int.Parse(arrvalue[0]), nameNew);
                            if (isUpdate)
                            {
                                message = "";
                                //Xóa ảnh cũ đi:
                                imgProcess.DeleteFile(_path + arrvalue[1]);
                                return(message);
                            }
                            else
                            {
                                //Lỗi không thể cập nhật vào cơ sở dữ liệu. Xóa ảnh vừa upload lên đi.
                                imgProcess.DeleteFile(_path + nameNew);
                                message = "Lỗi kết nối SQL server. Không thể cập nhật được ảnh. Xin hãy thử lại";
                                return(message);
                            }
                        }
                        else
                        {
                            message = "Lỗi mạng hoặc không có quyền tạo file trong thư mục ảnh sản phẩm. Không thể Upload file ảnh. Xin bạn hãy thử lại";
                            return(message);
                        }
                    }
                }
            }
        }
        catch
        {
            message = "Có các lỗi sau đây: Không có quyền tạo file trong thư mục ảnh sản phẩm. Hoặc không cập nhật được vào CSDL. Hoặc ảnh bạn chọn không còn tồn tại. Xin bạn hãy thử lại";
        }
        return(message);
    }
Exemplo n.º 3
0
    protected void btadd_ServerClick(object sender, EventArgs e)
    {
        try
        {
            string title   = txttitle.Value.Trim();
            int    idBrand = int.Parse(slBrand.Value);
            content = Request.Form["txtContent"].ToString().Trim();
            string link = txtlink.Value.Trim();
            string Url1 = nameurl1;
            string Url2 = nameurl2;
            int    sort = int.Parse(slsort.Value.ToString().Trim());
            if (title.Length > 0)
            {
                DateTime time = new DateTime();
                time = DateTime.Now;
                CvalidateImageForPost manageImage = new CvalidateImageForPost();
                AdvertiseSystem       Advertise   = new AdvertiseSystem();
                if (ImageArticle1.PostedFile.FileName.Length > 0)
                {
                    Url1 = "special_1" + time.Ticks + "." + manageImage.GetExtension(ImageArticle1.PostedFile.FileName);
                }
                if (ImageArticle2.PostedFile.FileName.Length > 0)
                {
                    Url2 = "special_2" + time.Ticks + "." + manageImage.GetExtension(ImageArticle2.PostedFile.FileName);
                }
                Boolean test = Advertise.SpecialUpdate(id, idBrand, title, content, Url1, Url2, link, sort);
                if (test)
                {
                    diverror.Visible   = true;
                    diverror.InnerHtml = "Quảng cáo đặc biệt đã được chỉnh sửa";
                    string path = Server.MapPath("../image/advertise/");
                    if (ImageArticle1.PostedFile.FileName.Length > 0)
                    {
                        if (manageImage.TestTypeFile(ImageArticle1))
                        {
                            if (manageImage.TestMaxSizeImage(ImageArticle1, 84280))
                            {
                                diverror.InnerHtml += "<br />Ảnh nhỏ không quá 70KB";
                            }
                            else
                            {
                                manageImage.UploadFile_server(ImageArticle1, path + Url1);
                                manageImage.DeleteFile(path + nameurl1);
                                urlOld1 = "../image/advertise/" + Url1;
                            }
                        }
                        else
                        {
                            diverror.InnerHtml += "<br />Chỉ hỗ trợ file dạng: gif, png, jpg, bmp, swf";
                        }
                    }

                    if (ImageArticle2.PostedFile.FileName.Length > 0)
                    {
                        if (manageImage.TestTypeFile(ImageArticle2))
                        {
                            if (manageImage.TestMaxSizeImage(ImageArticle2, 122880))
                            {
                                diverror.InnerHtml += "<br />Ảnh to không quá 120KB";
                            }
                            else
                            {
                                manageImage.UploadFile_server(ImageArticle2, path + Url2);
                                manageImage.DeleteFile(path + nameurl2);
                                urlOld2 = "../image/advertise/" + Url2;
                            }
                        }
                        else
                        {
                            diverror.InnerHtml += "<br />Chỉ hỗ trợ file dạng: gif, png, jpg, bmp, swf";
                        }
                    }
                }
                else
                {
                    diverror.Visible   = true;
                    diverror.InnerHtml = "Lỗi kết nối, xin hãy thử lại";
                }
            }
            else
            {
                diverror.Visible   = true;
                diverror.InnerHtml = "Xin hãy nhập tiêu đề";
            }
        }
        catch
        {
            diverror.Visible   = true;
            diverror.InnerHtml = "Xin hãy nhập tiêu đề";
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string menu      = Request.QueryString["menu"].ToString();
            string strmobile = "";
            switch (menu)
            {
            case ("imgpro"):
            {
                try
                {
                    string id      = Request.QueryString["id"].ToString();
                    string name    = Request.QueryString["name"].ToString();
                    string namepro = Request.QueryString["namepro"].ToString();
                    string subName = "";
                    int    leng    = namepro.Length;
                    for (int i = 0; i < leng; i++)
                    {
                        if (namepro[i].Equals('('))
                        {
                            break;
                        }
                        if (!namepro[i].Equals(','))
                        {
                            subName += namepro[i];
                        }
                    }
                    subName = subName.Trim();
                    Session["SSIdProUpload"] = id + "," + name + "," + subName;
                }
                catch
                {
                }
                Response.Write("ok");
                break;
            }

            case ("bestsell"):
            {
                string strreturn = "";
                try
                {
                    string type = Request.QueryString["type"].ToString();
                    string id   = Request.QueryString["id"].ToString();
                    ProductBestSellSystem products = new ProductBestSellSystem();
                    Boolean test = products.ProductBestUpdate(int.Parse(id), int.Parse(type));
                    if (!test)
                    {
                        strreturn = "err";
                    }
                    else
                    {
                        //ProductMainPage_data ds = new ProductBestSellSystem().ProductBestSellAll();
                        //Application["appProductBestsell"] = ds.Tables[ProductMainPage_data._table];
                    }
                }
                catch
                {
                    strreturn = "err";
                }
                Response.Write(strreturn);
            }
            break;

            case ("justhave"):
            {
                string strreturn = "";
                try
                {
                    string type = Request.QueryString["type"].ToString();
                    string id   = Request.QueryString["id"].ToString();
                    ProductBestSellSystem products = new ProductBestSellSystem();
                    Boolean test = products.ProductJustHaveUpdate(int.Parse(id), int.Parse(type));
                    if (!test)
                    {
                        strreturn = "err";
                    }
                    else
                    {
                        //ProductMainPage_data ds = new ProductBestSellSystem().ProductBestSellAll();
                        //Application["appProductBestsell"] = ds.Tables[ProductMainPage_data._table];
                    }
                }
                catch
                {
                    strreturn = "err";
                }
                Response.Write(strreturn);
            }
            break;

            //prepare out:
            case ("prepareout"):
            {
                string PrepareStr = "";
                try
                {
                    string type = Request.QueryString["type"].ToString();
                    string id   = Request.QueryString["id"].ToString();
                    ProductBestSellSystem products = new ProductBestSellSystem();
                    Boolean test = products.ProductPrepareoutUpdate(int.Parse(id), int.Parse(type));
                    if (!test)
                    {
                        PrepareStr = "err";
                    }
                    else
                    {
                        //ProductMainPage_data ds = new ProductBestSellSystem().ProductBestSellAll();
                        //Application["appProductBestsell"] = ds.Tables[ProductMainPage_data._table];
                    }
                }
                catch
                {
                    PrepareStr = "err";
                }
                Response.Write(PrepareStr);
            }
            break;

            //proselloff:
            case ("proselloff"):
            {
                string strselloff = "";
                try
                {
                    string type  = Request.QueryString["type"].ToString();
                    string id    = Request.QueryString["id"].ToString();
                    float  price = float.Parse(Request.QueryString["price"].ToString());
                    ProductBestSellSystem products = new ProductBestSellSystem();
                    Boolean test = products.ProductSelloffUpdate(int.Parse(id), int.Parse(type), price);
                    if (!test)
                    {
                        strselloff = "err";
                    }
                    else
                    {
                        //ProductMainPage_data ds = new ProductBestSellSystem().ProductBestSellAll();
                        //Application["appProductBestsell"] = ds.Tables[ProductMainPage_data._table];
                    }
                }
                catch
                {
                    strselloff = "err";
                }
                Response.Write(strselloff);
            }
            break;

            case ("mainpage"):
                string strmain = "";
                try
                {
                    string type = Request.QueryString["type"].ToString();
                    string id   = Request.QueryString["id"].ToString();
                    string sort = Request.QueryString["sort"].ToString();
                    ProductMainPageSystem products = new ProductMainPageSystem();
                    Boolean test = products.ProductMainpageUpdate(int.Parse(id), int.Parse(type), int.Parse(sort));
                    if (!test)
                    {
                        strmain = "err";
                    }
                }
                catch
                {
                    strmain = "err";
                }
                Response.Write(strmain);
                break;

            case ("original"):
                string stroriginal = "";
                try
                {
                    string type = Request.QueryString["type"].ToString();
                    string id   = Request.QueryString["id"].ToString();
                    string sort = Request.QueryString["sort"].ToString();
                    ProductMainPageSystem products = new ProductMainPageSystem();
                    Boolean test = products.ProductOriginalUpdate(int.Parse(id), int.Parse(type), int.Parse(sort));
                    if (!test)
                    {
                        stroriginal = "err";
                    }
                }
                catch
                {
                    strmain = "err";
                }
                Response.Write(stroriginal);
                break;

            case ("dgroup"):
                string strdelete = "";
                try
                {
                    string id = Request.QueryString["id"].ToString();
                    ArticleManagerSystem Articles = new ArticleManagerSystem();

                    if (Articles.AdminGroupDeleteId(id))
                    {
                        strdelete = "1";
                    }
                    else
                    {
                        strdelete = "0";
                    }
                }catch
                {
                    strdelete = "0";
                }
                Response.Write(strdelete);
                break;

            case ("dgcontact"):
                string strdcontact = "";
                try
                {
                    string         id       = Request.QueryString["id"].ToString();
                    ContacstSystem Contacts = new ContacstSystem();

                    if (Contacts.GroupContactDeleteId(id))
                    {
                        strdcontact = "1";
                    }
                    else
                    {
                        strdcontact = "0";
                    }
                }
                catch
                {
                    strdcontact = "0";
                }
                Response.Write(strdcontact);
                break;

            case ("dglocation"):
                string strdlocation = "";
                try
                {
                    string         id       = Request.QueryString["id"].ToString();
                    ContacstSystem Contacts = new ContacstSystem();

                    if (Contacts.LocationContactDelete(id))
                    {
                        strdlocation = "1";
                    }
                    else
                    {
                        strdlocation = "0";
                    }
                }
                catch
                {
                    strdlocation = "0";
                }
                Response.Write(strdlocation);
                break;

            case ("dhelp"):
                string strdhelp = "0";
                try
                {
                    string      id    = Request.QueryString["id"].ToString();
                    HelpsSystem helps = new HelpsSystem();

                    if (helps.HelpsDelete(id))
                    {
                        strdhelp = "1";
                    }
                }
                catch
                {
                    strdhelp = "0";
                }
                Response.Write(strdhelp);
                break;

            case ("donline"):
                string stronline = "0";
                try
                {
                    string id = Request.QueryString["id"].ToString();
                    SupportOnlineSystem Support = new SupportOnlineSystem();
                    if (Support.OnlineDelete(id))
                    {
                        stronline = "1";
                        Application["appOnline"] = null;
                    }
                }
                catch
                {
                    stronline = "0";
                }
                Response.Write(stronline);
                break;

            case ("dadvertise"):
                string strdadvertise = "0";
                try
                {
                    string          id        = Request.QueryString["id"].ToString();
                    AdvertiseSystem advertise = new AdvertiseSystem();
                    DataSet         ds        = advertise.AdvertiseSelectId(id);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string url1 = ds.Tables[0].Rows[0]["urlimage"].ToString();
                        string path = Server.MapPath("../image/advertise/");
                        CvalidateImageForPost manageImage = new CvalidateImageForPost();
                        if (url1.Length > 0)
                        {
                            manageImage.DeleteFile(path + url1);
                        }
                    }
                    if (advertise.AdvertiseDelete(id))
                    {
                        strdadvertise = "1";
                        Application["appAdvertiset"] = null;
                    }
                }
                catch
                {
                    strdadvertise = "0";
                }
                Response.Write(strdadvertise);
                break;

            case ("dadvertisespecial"):
                string strspecial = "0";
                try
                {
                    string          id        = Request.QueryString["id"].ToString();
                    AdvertiseSystem advertise = new AdvertiseSystem();
                    DataSet         ds        = advertise.SpecialSelectId(int.Parse(id));
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string url1 = ds.Tables[0].Rows[0]["urlimage1"].ToString();
                        string url2 = ds.Tables[0].Rows[0]["urlimage2"].ToString();
                        string path = Server.MapPath("../image/advertise/");
                        CvalidateImageForPost manageImage = new CvalidateImageForPost();
                        if (url1.Length > 0)
                        {
                            manageImage.DeleteFile(path + url1);
                        }
                        if (url2.Length > 0)
                        {
                            manageImage.DeleteFile(path + url2);
                        }
                    }
                    if (advertise.SpecialDelete(id))
                    {
                        strspecial = "1";
                    }
                }
                catch
                {
                    strspecial = "0";
                }
                Response.Write(strspecial);
                break;

            case "darticle":
                string strdarticle = "0";
                try
                {
                    string id = Request.QueryString["id"].ToString();
                    ArticleManagerSystem article = new ArticleManagerSystem();
                    DataSet ds = article.ArticleSelectDetail(int.Parse(id));
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string url1 = ds.Tables[0].Rows[0]["urlimage"].ToString();
                        string path = Server.MapPath("../image/img_article/");
                        CvalidateImageForPost manageImage = new CvalidateImageForPost();
                        if (url1.Length > 0)
                        {
                            manageImage.DeleteFile(path + url1);
                        }
                    }
                    if (article.AdminArticleDelete(id))
                    {
                        strdarticle = "1";
                    }
                }
                catch
                {
                    strdarticle = "0";
                }
                Response.Write(strdarticle);
                break;

            //for mobile:
            case "mobile1":
                try
                {
                    string       type   = Request.QueryString["type"].ToString();
                    string       id     = Request.QueryString["id"].ToString();
                    string       sort   = Request.QueryString["sort"].ToString();
                    string       insert = Request.QueryString["insert"].ToString();
                    Mobilesystem Mobile = new Mobilesystem();
                    Boolean      test   = Mobile.MobileUpdate(int.Parse(id), int.Parse(insert), int.Parse(type), int.Parse(sort));
                    if (!test)
                    {
                        strmobile = "err";
                    }
                }
                catch
                {
                    strmobile = "err";
                }
                Response.Write(strmobile);
                break;
            }
        }
        catch
        {
        }
    }
Exemplo n.º 5
0
 protected void btadd_ServerClick(object sender, EventArgs e)
 {
     try
     {
         string title = txttitle.Value.Trim();
         string link  = txtlink.Value.Trim();
         int    sort  = int.Parse(slsort.Value);
         string ishow = "0";
         if (checkshow.Checked)
         {
             ishow = "1";
         }
         string note = txtnote.Value.Trim();
         if (title.Length == 0)
         {
             diverror.Visible   = true;
             diverror.InnerHtml = "<div class='diverror'>Xin hãy nhập tiêu đề liên kết</div>";
             return;
         }
         else if (link.Length == 0)
         {
             diverror.Visible   = true;
             diverror.InnerHtml = "<div class='diverror'>Xin hãy nhập Link liên kết</div>";
             return;
         }
         else
         {
             string   nameImage = "";
             DateTime time      = new DateTime();
             time = DateTime.Now;
             CvalidateImageForPost manageImage = new CvalidateImageForPost();
             if (ImageArticle.PostedFile.FileName.Length > 0)
             {
                 nameImage = "advertise" + time.Ticks + "." + manageImage.GetExtension(ImageArticle.PostedFile.FileName);
             }
             if (advertise.AdvertiseInsert(title, sort, link, nameImage, ishow, note))
             {
                 diverror.Visible   = true;
                 diverror.InnerHtml = "<div class='diverror'>Liên kết đã được thêm mới</div>";
                 //UpdateArticle:
                 txttitle.Value               = "";
                 txtnote.Value                = "";
                 txtlink.Value                = "";
                 checkshow.Checked            = true;
                 Application["appAdvertiset"] = null;
                 SetAdvertise();
                 if (ImageArticle.PostedFile.FileName.Length > 0)
                 {
                     if (manageImage.TestTypeFile(ImageArticle))
                     {
                         if (manageImage.TestMaxSizeImage(ImageArticle, 102400))
                         {
                             diverror.InnerHtml += "<div class='diverror'>Ảnh không quá 100KB</div>";
                         }
                         else
                         {
                             string path = Server.MapPath("../image/advertise/");
                             manageImage.UploadFile_server(ImageArticle, path + nameImage);
                         }
                     }
                     else
                     {
                         diverror.InnerHtml += "<div class='diverror'>Chỉ hỗ trợ file dạng: gif, png, jpg, bmp, swf</div>";
                     }
                 }
                 return;
             }
             else
             {
                 diverror.Visible   = true;
                 diverror.InnerHtml = "<div class='diverror'>Lỗi kết nối, không thể thêm mới liên kết</div>";
                 return;
             }
         }
     }
     catch
     { }
 }