예제 #1
0
 protected void btn第八張圖_Click(object sender, EventArgs e)
 {
     if (FileUpload8.HasFile)
     {
         string savePath = Server.MapPath(@"/./images/8.jpg");
         FileUpload8.SaveAs(savePath);
         lbl8.Visible = true;
         lbl8.Text    = "上傳成功";
     }
 }
예제 #2
0
    //上传聊天页面图片
    protected void Button6_Click(object sender, EventArgs e)
    {
        string bgStyle  = ConfigurationManager.AppSettings["UserDefinedPath"] + "\\Default\\chat_bg0.gif";
        string rightimg = this.FileUpload7.FileName;
        string topimg   = this.FileUpload8.FileName;

        if (string.IsNullOrEmpty(bgStyle) || string.IsNullOrEmpty(rightimg) || string.IsNullOrEmpty(topimg))
        {
            Label3.Text = "请选择上传图片";
            this.ModalPopupExtender3.Show();
            return;
        }
        if (!string.IsNullOrEmpty(LoadImageType(bgStyle)) || !string.IsNullOrEmpty(LoadImageType(rightimg)) || !string.IsNullOrEmpty(LoadImageType(topimg)))
        {
            Label3.Text = "图片,请上传格式为jpg,gif,png,bmp图片";
            this.ModalPopupExtender3.Show();
            return;
        }
        WebSite wst = WebSiteManager.GetWebSiteByDomainName(this.drpDomainName.SelectedValue);

        if (wst != null)
        {
            if (Session["User"] != null)
            {
                oper = (Operator)Session["User"];
                string path = ConfigurationManager.AppSettings["UserDefinedPath"] + "\\" + oper.Account.AccountNumber + "\\" + drpDomainName.SelectedValue;
                Directory.CreateDirectory(path);
                string aa           = LiveSupport.BLL.WebSiteManager.WebSite_UserDefined;
                string chatBGimg    = "chat_bg" + aa + Path.GetExtension(bgStyle);
                string chatRightimg = "chat_right" + aa + Path.GetExtension(rightimg);
                string leaveTopimg  = "leave_top" + aa + Path.GetExtension(topimg);
                File.Copy(bgStyle, path + "\\" + chatBGimg, true);
                FileUpload7.SaveAs(path + "\\" + chatRightimg);
                FileUpload8.SaveAs(path + "\\" + leaveTopimg);
                wst.ChatStyle = aa + "|" + chatBGimg + "|" + chatRightimg + "|" + leaveTopimg;
                WebSiteManager.Update(wst);
                AddIcoLocation(wst.IcoLocation);
                AddBannerStyle(wst.IconStyle);
                AddInviteStyle(wst.InviteStyle);
                AddChatStyle(wst.ChatStyle);
            }
            else
            {
                Response.Redirect("../Index.aspx");
            }
        }
        else
        {
            Response.Write("<script>alert('请选择上传到那个域名!');</script>");
        }
    }
예제 #3
0
    protected void Button9_Click(object sender, EventArgs e)
    {
        string strMsgSuccess = "Upload Success";
        string strMsgSelect  = "Please select your file";

        if (FileUpload8.HasFile)
        {
            String strFileName = FileUpload8.FileName;
            FileUpload8.SaveAs(Server.MapPath("lecture8/" + strFileName));
            //Response.Write("<script> alert('Upload Success');<script>");
            TextBox8.Text = strMsgSuccess;
        }
        else
        {
            //Response.Write("<script> alert('Pleases select your file');<script>");
            TextBox8.Text = strMsgSelect;
        }
    }
예제 #4
0
 void imageup()
 {
     if (FileUpload1.HasFile)
     {
         FileUpload1.SaveAs(Server.MapPath("/profilepics/") + FileUpload1.FileName);
         image[1] = "~/profilepics/" + FileUpload1.FileName;
         count++;
     }
     else
     {
         image[1] = "";
     }
     if (FileUpload2.HasFile)
     {
         FileUpload2.SaveAs(Server.MapPath("/profilepics/") + FileUpload2.FileName);
         image[2] = "~/profilepics/" + FileUpload2.FileName;
         count++;
     }
     else
     {
         image[2] = "";
     }
     if (FileUpload3.HasFile)
     {
         FileUpload3.SaveAs(Server.MapPath("/profilepics/") + FileUpload3.FileName);
         image[3] = "~/profilepics/" + FileUpload3.FileName;
         count++;
     }
     else
     {
         image[3] = "";
     }
     if (FileUpload4.HasFile)
     {
         FileUpload4.SaveAs(Server.MapPath("/profilepics/") + FileUpload4.FileName);
         image[4] = "~/profilepics/" + FileUpload4.FileName;
         count++;
     }
     else
     {
         image[4] = "";
     }
     if (FileUpload5.HasFile)
     {
         FileUpload5.SaveAs(Server.MapPath("/profilepics/") + FileUpload5.FileName);
         image[5] = "~/profilepics/" + FileUpload5.FileName;
         count++;
     }
     else
     {
         image[5] = "";
     }
     if (FileUpload6.HasFile)
     {
         FileUpload6.SaveAs(Server.MapPath("/profilepics/") + FileUpload6.FileName);
         image[6] = "~/profilepics/" + FileUpload6.FileName;
         count++;
     }
     else
     {
         image[6] = "";
     }
     if (FileUpload7.HasFile)
     {
         FileUpload7.SaveAs(Server.MapPath("/profilepics/") + FileUpload7.FileName);
         image[7] = "~/profilepics/" + FileUpload7.FileName;
         count++;
     }
     else
     {
         image[7] = "";
     }
     if (FileUpload8.HasFile)
     {
         FileUpload8.SaveAs(Server.MapPath("/profilepics/") + FileUpload8.FileName);
         image[8] = "~/profilepics/" + FileUpload8.FileName;
         count++;
     }
     else
     {
         image[8] = "";
     }
     if (FileUpload9.HasFile)
     {
         FileUpload9.SaveAs(Server.MapPath("/profilepics/") + FileUpload9.FileName);
         image[9] = "~/profilepics/" + FileUpload9.FileName;
         count++;
     }
     else
     {
         image[9] = "";
     }
     if (FileUpload10.HasFile)
     {
         FileUpload10.SaveAs(Server.MapPath("/profilepics/") + FileUpload10.FileName);
         image[10] = "~/profilepics/" + FileUpload10.FileName;
         count++;
     }
     else
     {
         image[10] = "";
     }
 }
예제 #5
0
        protected void SaveInfo()
        {
            DateTime DateRange      = new DateTime();
            DateTime DateExpiration = new DateTime();

            if (txtDateRange.Text != "")
            {
                DateRange = DateTime.ParseExact(txtDateRange.Text, "dd/MM/yyyy", null);
            }
            if (txtDateExpiration.Text != "")
            {
                DateExpiration = DateTime.ParseExact(txtDateExpiration.Text, "dd/MM/yyyy", null);
            }
            Cooperative_Info cop = new Cooperative_Info();

            cop.Cooperative_Key    = Convert.ToInt32(lbkey.Text);
            cop.Cooperative_ID     = txtCooperative_ID.Text;
            cop.Cooperative_Name   = txtCooperative_Name.Text;
            cop.ProvincesCities_ID = ddProvincesCitiesID.SelectedValue;
            cop.Address            = txtAddress.Text;
            cop.VietGAPCode        = txtVietGAPCode.Text;
            cop.Phone                 = txtPhone.Text;
            cop.Members               = Convert.ToInt32(txtMembers.Text);
            cop.Area                  = Convert.ToInt32(txtArea.Text);
            cop.Quantity              = Convert.ToInt32(txtQuantity.Text);
            cop.TreeType              = txtTreeType.Text;
            cop.DateRange             = DateRange;
            cop.DateExpiration        = DateExpiration;
            cop.Owner                 = txtOwner.Text;
            cop.Description           = txtDescription.Text;
            cop.CertifiedOrganization = ddCertifiedOrganization.SelectedValue;
            string[] arrListStr = txtlat.Text.Split(',');
            cop.Lat    = arrListStr[0];
            cop.Lng    = arrListStr[1];
            cop.Images = ddImage.SelectedValue;
            if (FileUploadControl.HasFile)
            {
                try
                {
                    string filename = Path.GetFileName(FileUploadControl.FileName);
                    FileUploadControl.SaveAs(Server.MapPath("~/Img/Tree/") + filename);
                    cop.Images = filename;
                }
                catch (Exception ex) {}
            }
            cop.Save();
            Cooperative_Image_Info cooImg = new Cooperative_Image_Info();

            if (FileUpload1.HasFile)
            {
                try{
                    string Name = lbkey.Text + "_1";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img1.png";
                    FileUpload1.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }catch (Exception ex) { }
            }
            if (FileUpload2.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_2";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img2.png";
                    FileUpload2.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload3.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_3";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img3.png";
                    FileUpload3.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload4.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_4";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img4.png";
                    FileUpload4.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload5.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_5";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img5.png";
                    FileUpload5.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload6.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_6";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img6.png";
                    FileUpload6.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload7.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_7";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img7.png";
                    FileUpload7.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload8.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_8";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img8.png";
                    FileUpload8.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload9.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_9";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img9.png";
                    FileUpload9.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
            if (FileUpload10.HasFile)
            {
                try
                {
                    string Name = lbkey.Text + "_10";
                    Cooperative_Image_Info cooImgName = new Cooperative_Image_Info(Name);
                    cooImg.Cooperative_Image_Key = cooImgName.Cooperative_Image_Key;
                    cooImg.Name            = Name;
                    cooImg.Cooperative_Key = Convert.ToInt32(lbkey.Text);
                    cooImg.DateTime        = DateTime.Now;
                    cooImg.Description     = txtCooperative_Name.Text;
                    string filename = lbkey.Text + "_img10.png";
                    FileUpload10.SaveAs(Server.MapPath("~/Img/coop/") + filename);
                    cooImg.Images = "../Img/coop/" + filename;
                    cooImg.Save();
                }
                catch (Exception ex) { }
            }
        }
    protected void Button7_Click(object sender, EventArgs e)
    {
        try
        {
            if (FileUpload1.HasFile || FileUpload2.HasFile || FileUpload3.HasFile || FileUpload4.HasFile || FileUpload5.HasFile || FileUpload6.HasFile || FileUpload7.HasFile || FileUpload8.HasFile || FileUpload9.HasFile || FileUpload10.HasFile || FileUpload11.HasFile || FileUpload12.HasFile || FileUpload13.HasFile || FileUpload14.HasFile || FileUpload15.HasFile || FileUpload16.HasFile || FileUpload17.HasFile || FileUpload18.HasFile || FileUpload19.HasFile || FileUpload20.HasFile || FileUpload21.HasFile || FileUpload22.HasFile || FileUpload23.HasFile || FileUpload24.HasFile || FileUpload25.HasFile || FileUpload26.HasFile || FileUpload27.HasFile || FileUpload28.HasFile || FileUpload29.HasFile || FileUpload30.HasFile || FileUpload31.HasFile || FileUpload32.HasFile || FileUpload33.HasFile || FileUpload34.HasFile || FileUpload35.HasFile || FileUpload36.HasFile || FileUpload37.HasFile || FileUpload38.HasFile || FileUpload39.HasFile)
            {
                string path = Server.MapPath("Images/");

                //HOME
                if (FileUpload1.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload1.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload1.SaveAs(path + FileUpload1.FileName);
                        string name = "Images/" + FileUpload1.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=14";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload2.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload2.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload2.SaveAs(path + FileUpload2.FileName);
                        string name = "Images/" + FileUpload2.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=14";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload3.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload3.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload3.SaveAs(path + FileUpload3.FileName);
                        string name = "Images/" + FileUpload3.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=14";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //BUY FLAT
                if (FileUpload4.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload4.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload4.SaveAs(path + FileUpload4.FileName);
                        string name = "Images/" + FileUpload4.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=1";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload5.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload5.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload5.SaveAs(path + FileUpload5.FileName);
                        string name = "Images/" + FileUpload5.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=1";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload6.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload6.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload6.SaveAs(path + FileUpload6.FileName);
                        string name = "Images/" + FileUpload6.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=1";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //BUY HOUSE
                if (FileUpload7.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload7.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload7.SaveAs(path + FileUpload7.FileName);
                        string name = "Images/" + FileUpload7.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=2";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload8.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload8.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload8.SaveAs(path + FileUpload8.FileName);
                        string name = "Images/" + FileUpload8.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=2";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload9.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload9.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload9.SaveAs(path + FileUpload9.FileName);
                        string name = "Images/" + FileUpload9.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=2";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //BUY VILLA
                if (FileUpload10.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload10.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload10.SaveAs(path + FileUpload10.FileName);
                        string name = "Images/" + FileUpload10.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=3";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload11.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload11.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload11.SaveAs(path + FileUpload11.FileName);
                        string name = "Images/" + FileUpload11.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=3";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload12.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload12.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload12.SaveAs(path + FileUpload12.FileName);
                        string name = "Images/" + FileUpload12.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=3";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //BUY LUXURY HOUSE
                if (FileUpload13.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload13.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload13.SaveAs(path + FileUpload13.FileName);
                        string name = "Images/" + FileUpload13.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=5";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload14.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload14.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload14.SaveAs(path + FileUpload14.FileName);
                        string name = "Images/" + FileUpload14.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=5";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload15.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload15.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload15.SaveAs(path + FileUpload15.FileName);
                        string name = "Images/" + FileUpload15.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=5";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //BUY BUDGET DEAL
                if (FileUpload16.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload16.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload16.SaveAs(path + FileUpload16.FileName);
                        string name = "Images/" + FileUpload16.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=6";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload17.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload17.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload17.SaveAs(path + FileUpload17.FileName);
                        string name = "Images/" + FileUpload17.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=6";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload18.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload18.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload18.SaveAs(path + FileUpload18.FileName);
                        string name = "Images/" + FileUpload18.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=6";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //RENT FLAT
                if (FileUpload19.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload19.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload19.SaveAs(path + FileUpload19.FileName);
                        string name = "Images/" + FileUpload19.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=7";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload20.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload20.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload20.SaveAs(path + FileUpload20.FileName);
                        string name = "Images/" + FileUpload20.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=7";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload21.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload21.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload21.SaveAs(path + FileUpload21.FileName);
                        string name = "Images/" + FileUpload21.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=7";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //RENT HOUSE
                if (FileUpload22.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload22.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload22.SaveAs(path + FileUpload22.FileName);
                        string name = "Images/" + FileUpload22.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=8";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload23.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload23.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload23.SaveAs(path + FileUpload23.FileName);
                        string name = "Images/" + FileUpload23.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=8";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload24.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload24.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload24.SaveAs(path + FileUpload24.FileName);
                        string name = "Images/" + FileUpload24.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=8";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //RENT VILLA
                if (FileUpload25.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload25.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload25.SaveAs(path + FileUpload25.FileName);
                        string name = "Images/" + FileUpload25.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=9";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload26.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload26.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload26.SaveAs(path + FileUpload26.FileName);
                        string name = "Images/" + FileUpload26.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=9";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload27.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload27.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload27.SaveAs(path + FileUpload27.FileName);
                        string name = "Images/" + FileUpload27.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=9";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //RENT BACHELOR FRIENDLY
                if (FileUpload28.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload28.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload28.SaveAs(path + FileUpload28.FileName);
                        string name = "Images/" + FileUpload28.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=10";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload29.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload29.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload29.SaveAs(path + FileUpload29.FileName);
                        string name = "Images/" + FileUpload29.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=10";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload30.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload30.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload30.SaveAs(path + FileUpload30.FileName);
                        string name = "Images/" + FileUpload30.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=10";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //RENT BUDGET DEAL
                if (FileUpload31.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload31.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload31.SaveAs(path + FileUpload31.FileName);
                        string name = "Images/" + FileUpload31.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=11";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload32.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload32.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload32.SaveAs(path + FileUpload32.FileName);
                        string name = "Images/" + FileUpload32.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=11";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload33.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload33.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload33.SaveAs(path + FileUpload33.FileName);
                        string name = "Images/" + FileUpload33.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=11";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //OFFICE SPACE
                if (FileUpload34.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload34.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload34.SaveAs(path + FileUpload34.FileName);
                        string name = "Images/" + FileUpload34.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=11";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload35.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload35.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload35.SaveAs(path + FileUpload35.FileName);
                        string name = "Images/" + FileUpload35.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=12";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload36.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload36.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload36.SaveAs(path + FileUpload36.FileName);
                        string name = "Images/" + FileUpload36.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=12";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //BHK FLAT
                if (FileUpload37.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload37.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload37.SaveAs(path + FileUpload37.FileName);
                        string name = "Images/" + FileUpload37.FileName;
                        string ss   = "update slider set image1='" + name + "' where id=13";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload38.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload38.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload38.SaveAs(path + FileUpload38.FileName);
                        string name = "Images/" + FileUpload38.FileName;
                        string ss   = "update slider set image2='" + name + "' where id=13";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                if (FileUpload39.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload39.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload39.SaveAs(path + FileUpload39.FileName);
                        string name = "Images/" + FileUpload39.FileName;
                        string ss   = "update slider set image3='" + name + "' where id=13";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                count++;
                Response.Redirect("adminpanel-slider.aspx");
            }
            else
            {
                a++;
                Response.Redirect("adminpanel-slider.aspx");
            }
        }

        catch (Exception)
        {
            Label2.Visible = true;
        }
    }
예제 #7
0
    protected void Button7_Click(object sender, EventArgs e)
    {
        try{
            if (FileUpload1.HasFile || FileUpload2.HasFile || FileUpload3.HasFile || FileUpload4.HasFile || FileUpload5.HasFile || FileUpload6.HasFile || FileUpload7.HasFile || FileUpload8.HasFile || FileUpload9.HasFile || FileUpload10.HasFile)
            {
                string path = Server.MapPath("Images/");

                //first
                if (FileUpload1.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload1.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload1.SaveAs(path + FileUpload1.FileName);
                        string name = "Images/" + FileUpload1.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox1.Text + "',city='" + TextBox2.Text + "',contentt='" + TextBox3.Text + "' where id=1";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //second
                if (FileUpload2.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload2.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload2.SaveAs(path + FileUpload2.FileName);
                        string name = "Images/" + FileUpload2.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox4.Text + "',city='" + TextBox5.Text + "',contentt='" + TextBox6.Text + "' where id=2";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //third
                if (FileUpload3.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload3.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload3.SaveAs(path + FileUpload3.FileName);
                        string name = "Images/" + FileUpload3.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox7.Text + "',city='" + TextBox8.Text + "',contentt='" + TextBox9.Text + "' where id=3";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //forth
                if (FileUpload4.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload4.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload4.SaveAs(path + FileUpload4.FileName);
                        string name = "Images/" + FileUpload4.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox10.Text + "',city='" + TextBox11.Text + "',contentt='" + TextBox12.Text + "' where id=4";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //fifth
                if (FileUpload5.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload5.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload5.SaveAs(path + FileUpload5.FileName);
                        string name = "Images/" + FileUpload5.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox13.Text + "',city='" + TextBox14.Text + "',contentt='" + TextBox15.Text + "' where id=5";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //sixth
                if (FileUpload6.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload6.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload6.SaveAs(path + FileUpload6.FileName);
                        string name = "Images/" + FileUpload6.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox16.Text + "',city='" + TextBox17.Text + "',contentt='" + TextBox18.Text + "' where id=6";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //first
                if (FileUpload7.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload7.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload7.SaveAs(path + FileUpload7.FileName);
                        string name = "Images/" + FileUpload7.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox19.Text + "',city='" + TextBox20.Text + "',contentt='" + TextBox21.Text + "' where id=7";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //eighth
                if (FileUpload8.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload8.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload8.SaveAs(path + FileUpload8.FileName);
                        string name = "Images/" + FileUpload8.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox22.Text + "',city='" + TextBox23.Text + "',contentt='" + TextBox24.Text + "' where id=8";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                //nineth
                if (FileUpload9.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload9.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload9.SaveAs(path + FileUpload9.FileName);
                        string name = "Images/" + FileUpload9.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox25.Text + "',city='" + TextBox26.Text + "',contentt='" + TextBox27.Text + "' where id=9";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }
                //tenth
                if (FileUpload10.HasFile)
                {
                    string ext = Path.GetExtension(FileUpload10.FileName);
                    if (ext == ".jpg" || ext == ".png")
                    {
                        FileUpload10.SaveAs(path + FileUpload10.FileName);
                        string name = "Images/" + FileUpload10.FileName;
                        string ss   = "update user_review set image='" + name + "', name='" + TextBox28.Text + "',city='" + TextBox29.Text + "',contentt='" + TextBox30.Text + "' where id=10";

                        con.Open();
                        cmd = new SqlCommand(ss, con);
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }

                count++;
                Response.Redirect("adminpanel-user-review.aspx");
            }
            else
            {
                a++;
                Response.Redirect("adminpanel-user-review.aspx");
            }
        }

        catch (Exception)
        {
            Label2.Visible = true;
        }
    }