protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Hashtable hash = (Hashtable)Application[Session["langcurrent"].ToString()];
            tblComponent = hash["component"].ToString();
        }
        catch
        {

        }
        if (Application["appgroupcom"] != null)
        {
            strGroupcom = Application["appgroupcom"].ToString();
        }
        else
        {
            try
            {
                DataSet dscom = new ComponentProductSystem().ComponentGroup((int)Application["idtypeproduct"]);
                int num = dscom.Tables[0].Rows.Count;
                for (int i = 0; i < num; i++)
                {
                    strGroupcom += "<a href='?menu=igc&id=" + dscom.Tables[0].Rows[i]["Id"].ToString() + "'>" + dscom.Tables[0].Rows[i]["Name"].ToString() + "</a><br />";
                }
                Application["appgroupcom"] = strGroupcom;
            }
            catch
            { }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Hashtable hash = (Hashtable)Application[Session["langcurrent"].ToString()];
            tblComponent = hash["component"].ToString();
            seeAll = hash["sapro"].ToString();
        }
        catch
        {

        }
        try
        {
            DataSet dscom = new ComponentProductSystem().ComponentGroupSale((int)Application["idtypeproduct"]);
            int num = dscom.Tables[0].Rows.Count;
            strGroupcom = "<a href='default.html?menu=com'>" + seeAll + "</a><br />";
            for (int i = 0; i < num; i++)
            {
                strGroupcom += "<a href='default.html?menu=igc&id=" + dscom.Tables[0].Rows[i]["Id"].ToString() + "'>" + dscom.Tables[0].Rows[i]["Name"].ToString() + "</a><br />";
            }
            //Application["appgroupcom"] = strGroupcom;
        }
        catch
        { }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["ProductInCart"] != null)
            {
                ManagerCart = (ManagerProcart)Session["ProductInCart"];
            }
            try
            {
                string id = Request.QueryString["id"].ToString();
                string type = Request.QueryString["type"].ToString();
                if (type.Equals("1") || type.Equals("3") || type.Equals("4"))
                {
                    if (id.Length > 0)
                    {
                        ProductSystem Product = new ProductSystem();
                        DataSet ds = Product.ProductToCart(id,"");
                        if (ds.Tables.Count > 0)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                proIncart.type = int.Parse(type);
                                proIncart.name = ds.Tables[0].Rows[0]["Name"].ToString() + " " + ds.Tables[0].Rows[0]["state"].ToString();
                                proIncart.urlImage = ds.Tables[0].Rows[0]["UrlImage"].ToString();
                                string strPrice = ds.Tables[0].Rows[0]["SellingPrice"].ToString();
                                if (strPrice.Length > 0)
                                {
                                    proIncart.price = float.Parse(strPrice);
                                }
                                string strwarranty = ds.Tables[0].Rows[0]["WarrantyMonth"].ToString();
                                if (strwarranty.Length > 0)
                                {
                                    proIncart.warranty = int.Parse(strwarranty);
                                }
                                proIncart.id = int.Parse(id);
                                proIncart.number = 1;
                                proIncart.currency = ds.Tables[0].Rows[0]["currency"].ToString();
                                proIncart.rate = float.Parse(ds.Tables[0].Rows[0]["rate"].ToString());
                                proIncart.setTotal();
                                ManagerCart.AddNewPro(proIncart);
                                Session["ProductInCart"] = ManagerCart;
                            }
                        }
                    }
                }
                else if(type.Equals("2"))
                {
                    //add component:
                    ComponentProductSystem Compoent = new ComponentProductSystem();
                    DataSet ds = Compoent.ComponenttoCart(id, Application["idtypeproduct"].ToString());
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            proIncart.type = 2;
                            proIncart.name = ds.Tables[0].Rows[0]["Name"].ToString();
                            proIncart.urlImage = ds.Tables[0].Rows[0]["UrlImage"].ToString();
                            string strPrice = ds.Tables[0].Rows[0]["SellingPrice"].ToString();
                            if (strPrice.Length > 0)
                            {
                                proIncart.price = float.Parse(strPrice);
                            }
                            string strwarranty = ds.Tables[0].Rows[0]["WarrantyMonth"].ToString();
                            if (strwarranty.Length > 0)
                            {
                                proIncart.warranty = int.Parse(strwarranty);
                            }
                            proIncart.id = int.Parse(id);
                            proIncart.number = 1;
                            proIncart.currency = ds.Tables[0].Rows[0]["currency"].ToString();
                            proIncart.rate = float.Parse(ds.Tables[0].Rows[0]["rate"].ToString());
                            proIncart.setTotal();
                            ManagerCart.AddNewPro(proIncart);
                            Session["ProductInCart"] = ManagerCart;
                        }
                    }
                }
                else if (type.Equals("11") || type.Equals("13") || type.Equals("14"))
                {
                    //delete product:
                    if (id.Length > 0)
                    {
                        proIncart.id = int.Parse(id);
                        if (type.Equals("11"))
                        {
                            proIncart.type = 1;
                        }
                        else if(type.Equals("13"))
                        {
                            proIncart.type = 3;
                        }
                        else if (type.Equals("14"))
                        {
                            proIncart.type = 4;
                        }
                        ManagerCart.DeletePro(proIncart);
                        Session["ProductInCart"] = ManagerCart;
                    }
                }
                else if (type.Equals("12"))
                {
                    //delete com:
                    if (id.Length > 0)
                    {
                        proIncart.id = int.Parse(id);
                        proIncart.type = 2;
                        ManagerCart.DeletePro(proIncart);
                        Session["ProductInCart"] = ManagerCart;
                    }
                }
            }
            catch
            {

            }
        }
        Response.Redirect("Default.aspx?menu=shoppingcart");
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     int id = 0;
     try
     {
         id = int.Parse(Request.QueryString["id"].ToString());
     }
     catch
     {
         Response.Redirect("?menu=com");
     }
     try
     {
         Hashtable hash = (Hashtable)Application[Session["langcurrent"].ToString()];
         bldetail = hash["detail"].ToString();
         thome = hash["home"].ToString();
         tpro = hash["component"].ToString();
         tname = hash["name"].ToString();
         tbrand = hash["brand"].ToString();
         tprice = hash["tprice"].ToString();
         twarranty = hash["twarranty"].ToString();
         twhere = hash["warehouse"].ToString();
         tstate = hash["state"].ToString();
         tnothave = hash["outstore"].ToString();
         tmonth = hash["tmonth"].ToString();
         torder = hash["torder"].ToString();
         tback = hash["bback"].ToString();
         //tcompare = hash["bcompare"].ToString();
         tdes = hash["des"].ToString();
         ttechnology = hash["specification"].ToString();
         tcurrentAccess = hash["currentpage"].ToString();
         tlistpro = hash["similar"].ToString();
         tgroup = hash["group"].ToString();
         tcurrentAccess += ": <a href='?menu=home'>" + thome + "</a> &raquo; <a href='?menu=com'>" + tpro + "</a> &raquo; ";
     }
     catch { }
     try
     {
         DataSet ds = new ComponentProductSystem().ComponentSelectDetail(id, (int)Application["idtypeproduct"]);
         GetDetailProduct(ds.Tables[0], ds.Tables[1]);
         if (strpro.Length > 0)
         {
             GetSpecification(ds.Tables[2]);
             GetGroupProduct(ds.Tables[3]);
         }
         else
         {
             Response.Redirect("?menu=com");
         }
     }
     catch
     {
         Response.Redirect("?menu=com");
     }
 }
 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, 20480))
                 {
                     message = "Kích thước ảnh không quá 20 KB";
                     return message;
                 }
                 else
                 {
                     string _path = Server.MapPath("../image/img_com/");
                     //FileInfo file=new FileInfo(_path+
                     string strgetTime = new CGetDataCommon().GetStrMonthDayYearSecondMinuteHour();
                     string nameNew = "com_" + arrvalue[0] + "_" + strgetTime + "." + imgProcess.GetExtension(file_name);
                     Boolean isUpload = imgProcess.UploadFile(file, _path + nameNew);
                     if (isUpload)
                     {
                         ComponentProductSystem ManagerPro = new ComponentProductSystem();
                         Boolean isUpdate = ManagerPro.ComponentUpdateImage(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;
 }
Example #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //SetOnline:
         myTitle = TitleDefault;
         myKey = KeyDefault;
         if (Session["online"] == null)
         {
             Session["online"] = true;
             SetVisited();
         }
         if (Application["idtypeproduct"] == null)
         {
             //Application["ratepromain"] = 1;
             SetAppTypeProduct();
         }
         Application["ratepromain"] = SetRateProduct(Application["idtypeproduct"].ToString());
         //For language support:
         if(Application["langsupport"] == null)
         {
             //Read Languagesupport:
             string _fileSupport = Server.MapPath("data/xml/language_support.xml");
             XmlDocument _docfile = new XmlDocument();
             XmlTextReader _reader = new XmlTextReader(_fileSupport);
             _docfile.Load(_reader);
             _reader.Close();
             XmlNodeList _listNode = _docfile.SelectNodes("/lang_support/lang");
             int numSupport = _listNode.Count;
             ArrayList _list = new ArrayList();
             string _urlFileLang=Server.MapPath("data/xml/");
             for (int i = 0; i < numSupport; i++)
             {
                 XmlNodeList _subList = _listNode[i].ChildNodes;
                 string[] arrvalue = new string[3] { "", "", "" };
                 arrvalue[0] = _subList[1].InnerText;
                 arrvalue[1] = _subList[3].InnerText;
                 arrvalue[2] = _subList[4].InnerText;
                 _list.Add(arrvalue);
                 GetApplication(arrvalue[1],_urlFileLang);
             }
             Application["langsupport"] = _list;
         }
         //for Session language current:
         if (Session["langcurrent"] == null)
         {
             ArrayList _list =(ArrayList)Application["langsupport"];
             string[] arrvalue = (string[])_list[0];
             Session["langcurrent"] = arrvalue[1];
         }
         if (Application["AppDownloadPrice"] == null)
         {
             StreamReader myFile1 = new StreamReader(Server.MapPath("data/file/Downloadprice.txt"));
             Application["AppDownloadPrice"] = myFile1.ReadToEnd();
             myFile1.Close();
         }
         plhheader.Controls.Add(Page.LoadControl("block/header.ascx"));
         plhmenu.Controls.Add(Page.LoadControl("block/menu.ascx"));
         plhsearchmenu.Controls.Add(Page.LoadControl("block/searchheader.ascx"));
         plhleft.Controls.Add(Page.LoadControl("block/left.ascx"));
         plhright.Controls.Add(Page.LoadControl("block/right.ascx"));
         plhcenter.Controls.Add(Page.LoadControl("block/center.ascx"));
         if (Application["AppFooter"] == null)
         {
             StreamReader myFile = new StreamReader(Server.MapPath("data/file/footer.txt"));
             footer = myFile.ReadToEnd();
             Application["AppFooter"] = footer;
             myFile.Close();
         }
         else
         {
             footer = Application["AppFooter"].ToString();
         }
         //Create title:
         string menu = "";
         if (Request.QueryString["menu"] != null)
         {
             menu = Request.QueryString["menu"].ToString();
             if (menu == "product")
             {
                 myTitle = "may tinh xach tay,máy tính xách tay,maytinhxachtay.com";
                 myKey = "may tinh xach tay - máy tính xách tay";
             }
             else if (menu == "com")
             {
                 myTitle = "linh kien may tinh, maytinhxachtay.com";
                 myKey = "linh kien may tinh";
             }
             else if (menu == "pro")
             {
                 if (Request.QueryString["brand"] != null)
                 {
                     string brandid = Request.QueryString["brand"];
                     DataSet dsbrand = new BrandProductSystem().BrandNameWhere("where id=" + brandid);
                     if (dsbrand.Tables.Count > 0 && dsbrand.Tables[0].Rows.Count > 0)
                     {
                         myTitle = "may tinh xach tay - " + dsbrand.Tables[0].Rows[0]["Name"] + ", maytinhxachtay.com";
                         myKey = "may tinh xach tay - " + dsbrand.Tables[0].Rows[0]["Name"];
                     }
                 }
             }
             else if (menu == "dc")
             {
                 if (Request.QueryString["id"] != null)
                 {
                     string id = Request.QueryString["id"];
                     DataSet dspro = new ComponentProductSystem().ComponentNameId(id);
                     if (dspro.Tables.Count > 0 && dspro.Tables[0].Rows.Count > 0)
                     {
                         myTitle = dspro.Tables[0].Rows[0]["Name"] + ", maytinhxachtay.com";
                         myKey = dspro.Tables[0].Rows[0]["Name"] + " - may tinh xach tay";
                     }
                 }
             }
             else if (menu == "dp" || menu == "dpda")
             {
                 if (Request.QueryString["id"] != null)
                 {
                     string id = Request.QueryString["id"];
                     DataSet dspro = new ProductSystem().ProductNameId(id);
                     if (dspro.Tables.Count > 0 && dspro.Tables[0].Rows.Count > 0)
                     {
                         myTitle = dspro.Tables[0].Rows[0]["Name"] + ", maytinhxachtay.com";
                         myKey = dspro.Tables[0].Rows[0]["Name"] + " - may tinh xach tay";
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
 }