protected void Add_Property_Click(object sender, EventArgs e)
        {
            #region Imge

            string folderPath = Server.MapPath("~/Upload/");

            //Check whether Directory (Folder) exists.
            if (!Directory.Exists(folderPath))
            {
                //If Directory (Folder) does not exists. Create it.
                Directory.CreateDirectory(folderPath);
            }

            //Save the File to the Directory (Folder).
            FileUpload_Image.SaveAs(folderPath + Path.GetFileName(FileUpload_Image.FileName));
            String FullPath = "../Upload/" + FileUpload_Image.FileName;

            #endregion
            objValue.Image        = FullPath.ToString();
            objValue.Price        = Convert.ToInt64(price.Text);
            objValue.PropertyName = Property_Name.Text;
            objValue.Address      = address.Text;
            objValue.Details      = details.Text;
            objValue.PropertyArea = Convert.ToInt64(Area.Text);
            objValue.Bedroom      = Convert.ToInt64(bed.Text);
            objValue.Bathroom     = Convert.ToInt64(Bath.Text);
            objValue.Flag         = "A";
            objValue.CreateDate   = System.DateTime.Now;
            objInteraction.PropertyDetailInsert(objValue);
            Response.Redirect("list.aspx");
        }
    /// <summary>
    /// 商户搜索配置导航 添加信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button_SaveSH_Click(object sender, EventArgs e)
    {
        //查询表中是否有记录,有责update,无则添加
        string sql     = "select count(*) from [Business_Suosuo] where businessuid='" + Session["uid"].ToString() + "'";
        string records = DB.FindString(sql);

        // 添加
        if (Convert.ToInt32(records) == 0)
        {
            string[] huozhui = FileUpload_Image.FileName.Split('.');
            string   file    = GetGuid.Guid() + "." + huozhui[1];
            FileUpload_Image.SaveAs(Server.MapPath("../material") + "\\" + file);
            string addsql = "insert into [Business_Suosuo](Businessmc,Businessimg,Businessaddress,tel,jianjie,xianshiyouhui,businessuid) values('" + TextBox_Businessmc.Text.Trim() + "','" + file + "','" + TextBox_address.Text.Trim() + "','" + TextBox_tel.Text.Trim() + "','" + TextBox_jj.Text.Trim() + "','" + DropDownList_yh.Text + "','" + Session["uid"].ToString() + "')";
            DB.execnonsql(addsql);
            Response.AddHeader("Refresh", "0");
        }
        else// 编辑
        {
            if (FileUpload_Image.FileName != "")
            {
                string[] huozhui = FileUpload_Image.FileName.Split('.');
                string   file    = GetGuid.Guid() + "." + huozhui[1];
                FileUpload_Image.SaveAs(Server.MapPath("../material") + "\\" + file);
                string addsql = "update  [Business_Suosuo] set Businessmc='" + TextBox_Businessmc.Text.Trim() + "',Businessimg='" + file + "',Businessaddress='" + TextBox_address.Text.Trim() + "',tel='" + TextBox_tel.Text.Trim() + "',jianjie='" + TextBox_jj.Text.Trim() + "',xianshiyouhui='" + DropDownList_yh.Text + "'  where businessuid='" + Session["uid"].ToString() + "'";
                DB.execnonsql(addsql);
                Response.AddHeader("Refresh", "0");
            }
            else
            {
                string addsql = "update  [Business_Suosuo] set Businessmc='" + TextBox_Businessmc.Text.Trim() + "',Businessaddress='" + TextBox_address.Text.Trim() + "',tel='" + TextBox_tel.Text.Trim() + "',jianjie='" + TextBox_jj.Text.Trim() + "',xianshiyouhui='" + DropDownList_yh.Text + "'  where businessuid='" + Session["uid"].ToString() + "'";
                DB.execnonsql(addsql);
                Response.AddHeader("Refresh", "0");
            }
        }
    }
        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (txt_ProductName.Text != "" && CKEditor_ProductDescription.Text != "" && txt_ProductPrice.Text != "" &&
                    txt_ProductStock.Text != "" && DropDownList_CategoriesProducts.SelectedValue != "")
                {
                    int IdPro = Convert.ToInt32(Request.Params["IdPro"].ToString());

                    res = tap.GetDataBy_IdProduct(IdPro);

                    string   ProductName         = txt_ProductName.Text;
                    string   ProductDescription  = CKEditor_ProductDescription.Text;
                    string   productImageUpdate  = "";
                    int      ProductCategory     = Convert.ToInt32(DropDownList_CategoriesProducts.SelectedValue.ToString());
                    int      ProductPrice        = Convert.ToInt32(txt_ProductPrice.Text);
                    int      ProductStock        = Convert.ToInt32(txt_ProductStock.Text);
                    int      ProductCreatedBy_Id = Convert.ToInt32(Session["Id_User"].ToString());
                    DateTime productCreatedAt    = Convert.ToDateTime(res[0].ProductCreatedAt.ToString());

                    if (FileUpload_Image.HasFile)
                    {
                        productImageUpdate = "~/Uploads/Product/" + FileUpload_Image.FileName;
                        FileUpload_Image.SaveAs(Server.MapPath(productImageUpdate));
                    }
                    else
                    {
                        productImageUpdate = res[0].ProductImage.ToString();
                    }


                    tap.Update(ProductName, productImageUpdate, ProductDescription, ProductCategory,
                               ProductStock, ProductPrice, ProductCreatedBy_Id, productCreatedAt, IdPro);

                    Response.Redirect("Products_By_Category_Update.aspx?IdCat=" + ProductCategory);

                    Response.Write("<script>alert('Information of this Product Updated');</script>");

                    /*string script = @"alert('Information of this Product Updated');
                     *      window.location.href = 'Products_By_Category_Update.aspx?IdPro='"+ IdPro+" ;";*/

                    //string script = @"alert('Information of this Product Updated');";

                    //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", script, true);

                    //talog.Insert("Update User", (string)Session["Username"], System.DateTime.Now);
                }
                else
                {
                    Response.Write("<script>alert('Fill in the fields correctly');</script>");
                }
            }
            catch (Exception error)
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alerta", "alert('The following error has occurred:  " + error.Message + " ');", true);
            }
        }
    protected void Nextv2_Click(object sender, EventArgs e)
    {
        //If we don't have a file yet
        if (!FileUpload_Image.HasFile)
        {
            Status.Text = "You need to select an image to upload.";
            return;
        }

        //If not a picture, return
        if (FileUpload_Image.PostedFile.ContentType != "image/jpeg" &&
            FileUpload_Image.PostedFile.ContentType != "image/jpg" &&
            FileUpload_Image.PostedFile.ContentType != "image/png")
        {
            Status.Text = "Can't upload that filetype.";
            return;
        }

        //Construct our save folder path
        string savePath = MapPath(@"/Uploads/" + Session["username"]);

        //If we don't have that username yet
        if (!Directory.Exists(savePath))
        {
            Directory.CreateDirectory(savePath);
        }

        //If we have a file by that name already, delete it
        if (File.Exists(savePath + @"\" + FileUpload_Image.FileName))
        {
            File.Delete(savePath + @"\" + FileUpload_Image.FileName);
        }

        try
        {
            FileUpload_Image.SaveAs(savePath + @"\" + FileUpload_Image.FileName);
        }
        catch
        {
            Status.Text = "Failed to save picture";
            return;
        }

        //Save our last pic filename
        LastUploadedPic.Value = FileUpload_Image.FileName;
        //Saved the file successfully
        Status.Text = $"Saved picture: {FileUpload_Image.FileName}";
        //Go to next view
        MultiView.ActiveViewIndex++;
    }
Beispiel #5
0
        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (txt_CategoryName.Text != "" && txt_CategoryDescription.Text != "" && DropDownList_Status.SelectedValue != "")
                {
                    int idCategory = Convert.ToInt32(Request.Params["IdCat"].ToString());

                    res = tac.GetDataBy_IdCategory(idCategory);

                    string CategoryName        = txt_CategoryName.Text;
                    string CategoryDescription = txt_CategoryDescription.Text;
                    string CategoryImageUpdate = "";
                    string CategoryStatus      = DropDownList_Status.SelectedItem.Text;

                    if (FileUpload_Image.HasFile)
                    {
                        CategoryImageUpdate = "~/Uploads/Category/" + FileUpload_Image.FileName;
                        FileUpload_Image.SaveAs(Server.MapPath(CategoryImageUpdate));
                    }
                    else
                    {
                        CategoryImageUpdate = res[0].CategoryImage.ToString();
                    }


                    tac.Update(txt_CategoryName.Text, CategoryImageUpdate, txt_CategoryDescription.Text,
                               DropDownList_Status.SelectedItem.Text, idCategory);

                    string script = @"alert('Information of Category Updated');
                            window.location.href='Admin_Categories.aspx';";

                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", script, true);

                    //talog.Insert("Update User", (string)Session["Username"], System.DateTime.Now);
                }
                else
                {
                    Response.Write("<script>alert('Fill in the fields correctly');</script>");
                }
            }
            catch (Exception error)
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alerta", "alert('The following error has occurred:  " + error.Message + " ');", true);
            }
        }
Beispiel #6
0
        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (txt_CategoryName.Text != "" && txt_CategoryDescription.Text != "" && FileUpload_Image.HasFile && DropDownList_Status.SelectedValue != "")
                {
                    string CategoryName        = txt_CategoryName.Text;
                    string CategoryDescription = txt_CategoryDescription.Text;
                    string CategoryImage       = "";
                    string CategoryStatus      = DropDownList_Status.SelectedItem.Text;

                    CategoryImage = "~/Uploads/Category/" + FileUpload_Image.FileName;
                    FileUpload_Image.SaveAs(Server.MapPath(CategoryImage));

                    res = tac.Bring_CategoryName(CategoryName);

                    if (res.Count == 0)
                    {
                        tac.Insert(CategoryName, CategoryImage, CategoryDescription, CategoryStatus);

                        Response.Write("<script>alert('User New add correctly');</script>");

                        Response.Redirect("Admin_Categories.aspx");

                        //talog.Insert("Registration of New User by Itself", (string)Session["Username"], System.DateTime.Now);
                    }
                    else
                    {
                        Response.Write("<script>alert('The Name of the Category Already Registered... Try again with other username');</script>");
                        txt_CategoryName.Focus();
                    }
                }
                else
                {
                    Response.Write("<script>alert('Fill in the fields correctly');</script>");
                }
            }
            catch (Exception error)
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alerta", "alert('The following error has occurred:  " + error.Message + " ');", true);
            }
        }
    protected void BT_Upload_Click(object sender, EventArgs e)
    {
        string uploadPath = Server.MapPath("../Images/ImageLienKet/");

        if (FileUpload_Image.HasFile)
        {
            string filename  = FileUpload_Image.FileName;
            string extension = System.IO.Path.GetExtension(filename);
            string savefile  = uploadPath + "\\" + filename;
            try
            {
                FileUpload_Image.SaveAs(savefile);
                IMG_Upload.ImageUrl = "../Images/ImageLienKet/" + filename;
                TB_PartImage.Value  = FileUpload_Image.FileName;
            }
            catch (Exception ex)
            {
                Trace.Write("-----Write File Error: \n" + ex.Message + "\n---------");
            }
        }
    }
Beispiel #8
0
        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (txt_ProductName.Text != "" && CKEditor_ProductDescription.Text != "" && txt_ProductPrice.Text != "" &&
                    txt_ProductStock.Text != "" && FileUpload_Image.HasFile &&
                    DropDownList_CategoriesProducts.SelectedValue != "")
                {
                    string ProductName         = txt_ProductName.Text;
                    string ProductDescription  = CKEditor_ProductDescription.Text;
                    string ProductImage        = "";
                    int    ProductCategory     = Convert.ToInt32(DropDownList_CategoriesProducts.SelectedValue.ToString());
                    int    ProductPrice        = Convert.ToInt32(txt_ProductPrice.Text);
                    int    ProductStock        = Convert.ToInt32(txt_ProductStock.Text);
                    int    ProductCreatedBy_Id = Convert.ToInt32(Session["Id_User"].ToString());

                    ProductImage = "~/Uploads/Product/" + FileUpload_Image.FileName;
                    FileUpload_Image.SaveAs(Server.MapPath(ProductImage));

                    tap.Insert(ProductName, ProductImage, ProductDescription, ProductCategory, ProductStock,
                               ProductPrice, ProductCreatedBy_Id, System.DateTime.Now);

                    Response.Redirect("Admin_Products.aspx");

                    //talog.Insert("Registration of New User by Itself", (string)Session["Username"], System.DateTime.Now);
                }
                else
                {
                    Response.Write("<script>alert('Fill in the fields correctly');</script>");
                }
            }
            catch (Exception error)
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alerta", "alert('The following error has occurred:  " + error.Message + " ');", true);
            }
        }
        protected void Submit_Slider_Click(object sender, EventArgs e)
        {
            try
            {
                #region Imageregion

                string folderPath = Server.MapPath("~/Upload/");

                //Check whether Directory (Folder) exists.
                if (!Directory.Exists(folderPath))
                {
                    //If Directory (Folder) does not exists. Create it.
                    Directory.CreateDirectory(folderPath);
                }

                //Save the File to the Directory (Folder).
                FileUpload_Image.SaveAs(folderPath + Path.GetFileName(FileUpload_Image.FileName));
                String FullPath = "../Upload/" + FileUpload_Image.FileName;

                #endregion


                objValue.SliderImage = FullPath.ToString();
                objValue.Title       = TextBox_Title.Text;
                objValue.Description = TextBox_Description.Text;
                objValue.Flag        = "A";
                objValue.CreateDate  = System.DateTime.Now;
                objInteraction.SliderInsert(objValue);
                TextBox_Title.Text       = "";
                TextBox_Description.Text = "";
                Slider_Bind();
            }
            catch (Exception ex)
            {
            }
        }
        protected void Button_Add_Click(object sender, EventArgs e)
        {
            UserModel model = new UserModel();

            model.UserName    = TextBox_UserName.Text;
            model.Account     = TextBox_Account.Text;
            model.CheckInTime = Convert.ToDateTime(TextBox_Born.Text);
            model.AlertTime   = DateTime.Now;
            model.PassWord    = TextBox_Password.Text;
            model.Phone       = TextBox_Phone.Text;
            model.Email       = TextBox_Email.Text;
            model.RoleId      = 1;
            model.IsDelete    = 0;
            model.Sex         = Convert.ToInt32(radlSex.SelectedItem.Value);
            UserBll bll = new UserBll();

            //上传用户头像
            if (FileUpload_Image.PostedFile.FileName.Trim().Length != 0)
            {
                string savePath;
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmssms");
                if (FileUpload_Image.HasFile && FileUpload_Image.PostedFile.FileName.Contains(".jpg"))
                {
                    //指定上传文件在服务器上的保存路径
                    savePath = Server.MapPath("~/Upload/");
                    //检查服务器上是否存在这个物理路径,如果不存在则创建
                    if (!System.IO.Directory.Exists(savePath))
                    {
                        System.IO.Directory.CreateDirectory(savePath);
                    }
                    savePath = savePath + fileName + ".jpg";
                    FileUpload_Image.SaveAs(savePath);
                    //model.ImagePath = "/Upload/" + fileName + ".jpg";
                    model.ImagePath = fileName + ".jpg";
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "alert('请选择JPG图片文件!');", true);
                    return;
                }
            }
            int result = 0;

            if (Request.QueryString["id"] != null)
            {
                model.UserID = Convert.ToInt32(Request.QueryString["id"]);
                result       = bll.UpdateUser(model);
            }
            else
            {
                result = bll.AddUser(model);
            }
            if (result > 0)
            {
                ClientScript.RegisterStartupScript(GetType(), "", "alert('保存成功!');window.location = 'UserList.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "alert('保存失败!');", true);
            }
        }