Esempio n. 1
0
        protected void btnAddPic_Click(object sender, EventArgs e)
        {
            UpLoadClass upload = new UpLoadClass();
            string filepath = upload.UpLoadImg(uploadpic, "/uploadfiles/pictures/");
            upload = null;

            List<PictureStore> list = (List<PictureStore>)ViewState["PicList"];
            PictureStore ps = new PictureStore();
            ps.PictureStoreName = txtPictureStoreName.Text.Trim();
            ps.PictureStoreGroupIDs = ddlPicGroup.SelectedValue;
            ps.PictureStoreDescription = txtPictureStoreDescriptioin.Text.Trim();
            ps.PictureStoreTagIDs = InfoAdmin.GetPictureStoreTagIDs(txtPictureStoreTag.Text.Trim());
            //ps.PictureStoreHits = 0;
            ps.PictureStoreCreateTime = DateTime.Now;

            //处理图片
            PicOperate po = new PicOperate();
            string newfilepath = filepath.Substring(0, filepath.LastIndexOf(".")) + "_new" + Path.GetExtension(filepath);
            po.AddWaterMarkOperate(Server.MapPath(filepath), Server.MapPath(WaterSettings.WaterMarkPath), Server.MapPath(newfilepath), WaterSettings.CopyrightText);
            //ps.PictureStoreRawUrl = newfilepath;
            //ps.PictureStoreLittleUrl = po.CreateMicroPic(newfilepath, "", WaterSettings.PictureScaleSize[0], WaterSettings.PictureScaleSize[1]);
            po = null;

            //更新图片标签
            ps.PictureStoreID = InfoAdmin.AddPictureStore(ps);
            foreach (string tagid in ps.PictureStoreTagIDs.Split(','))
            {
                InfoAdmin.SetPictureStoreTag(ps.PictureStoreID, int.Parse(tagid));
            }

            list.Add(ps);
            ViewState["PicList"] = list;

            this.bindPicList();
            this.clearText();
        }
Esempio n. 2
0
        protected void btnPicUpload1_OnClick(object sender, EventArgs e)
        {
            this.lblRedInfo.Visible = false;
            this.btnPicUpload.Enabled = false;

            if (uploadpic1.FileName == string.Empty || uploadpicsmall.Value == string.Empty)
            {
                this.lblRedInfo.Text = "上传大小图片地址不能为空!";
                this.lblRedInfo.Visible = true;
                this.btnPicUpload.Enabled = true;
                return;
            }

            PictureStore ps = (PictureStore)ViewState["PictureStoreInfo"];

            UpLoadClass upload = new UpLoadClass();
            string filepath = "";
            string newfilepath = upload.UploadImageFile(uploadpic1, "/uploadfiles/pictures/");
            PicOperate WaterMark = new PicOperate();

            //Water Mark Operation
            filepath = newfilepath.Substring(0, newfilepath.LastIndexOf(".")) + "_new" + System.IO.Path.GetExtension(newfilepath);

            WaterMark.AddWaterMarkOperate(newfilepath, Server.MapPath(WaterSettings.WaterMarkPath), filepath, WaterSettings.CopyrightText);

            filepath = GetPath(filepath);
            System.Threading.Thread.Sleep(1000);
            string filepathSmall = upload.UpLoadImg(uploadpicsmall, "/uploadfiles/pictures/");

            string hairStyleID = "";
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSqlServer"].ToString()))
            {
                string commString = "select id from HairStyle where PictureStoreId=" + ps.PictureStoreID.ToString();
                using (SqlCommand comm = new SqlCommand())
                {
                    comm.Connection = conn;
                    comm.CommandText = commString;
                    conn.Open();

                    using (SqlDataReader sdr = comm.ExecuteReader())
                    {
                        if (sdr.Read())
                        {
                            hairStyleID = sdr["id"].ToString();

                        }
                    }
                }
            }

            if (filepath != string.Empty)
            {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSqlServer"].ToString()))
                {
                    string commString = "insert into PictureStoreSet(PictureStoreId,PictureStoreURL,SmallPictureUrl,IsHairStyle,HairStylePos) values(" + hairStyleID + ",'" + filepath + "','" + filepathSmall + "',0,0)";
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.Connection = conn;
                        comm.CommandText = commString;
                        conn.Open();

                        try
                        {
                            comm.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        { }
                    }
                }
                int pssid = 0;
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSqlServer"].ToString()))
                {
                    string commString = "select top 1 * from PictureStoreSet where IsHairStyle=0 order by id desc";
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.Connection = conn;
                        comm.CommandText = commString;
                        conn.Open();

                        using (SqlDataReader sdr = comm.ExecuteReader())
                        {
                            if (sdr.Read())
                            {
                                pssid = Convert.ToInt32(sdr["ID"].ToString());
                            }
                        }
                    }
                }

                this.lblImg.Text = "<img src='" + filepathSmall + "' width=100 height=50 /><a href='" + filepath + "' target='_blank'><img src='" + filepath + "' width=200 height=100 /></a>&nbsp;&nbsp;<a href='PictureStoreOperate.aspx?id=" + pssid + "&pid=" + ps.PictureStoreID.ToString() + "'>删除</a>" + "&nbsp;&nbsp;" + this.lblImg.Text;

                this.btnPicUpload.Enabled = true;
            }
        }
Esempio n. 3
0
        protected void btnPicUpload1_OnClick(object sender, EventArgs e)
        {
            this.lblRedInfo.Visible = false;
            this.btnPicUpload.Enabled = false;
            if (uploadpic1.FileName == string.Empty || uploadpicsmall.Value == string.Empty)
            {
                this.lblRedInfo.Text = "上传大小图片地址均不能为空!";
                this.lblRedInfo.Visible = true;
                this.btnPicUpload.Enabled = true;
                return;
            }

            UpLoadClass upload = new UpLoadClass();
            string filepath = "";
            string newfilepath = upload.UploadImageFile(uploadpic1, "/uploadfiles/pictures/");
            PicOperate WaterMark = new PicOperate();

            //Water Mark Operation
            filepath = newfilepath.Substring(0, newfilepath.LastIndexOf(".")) + "_new" + System.IO.Path.GetExtension(newfilepath);

            WaterMark.AddWaterMarkOperate(newfilepath, Server.MapPath(WaterSettings.WaterMarkPath), filepath, WaterSettings.CopyrightText);

            filepath = GetPath(filepath);
            System.Threading.Thread.Sleep(1000);
            string filepathSmall = upload.UpLoadImg(uploadpicsmall, "/uploadfiles/pictures/");

            if (filepath != string.Empty)
            {
                int num = Convert.ToInt32(Session["num"].ToString());
                num++;
                Session["num"] = num;
                int picNum = int.Parse(Session["picNum"].ToString());
                picNum++;

                if (picNum == 1)
                {
                    Session["pic" + num.ToString()] = filepath;
                    Session["picSmall" + num.ToString()] = filepathSmall;

                    this.picString.Text = "<img width=100 heigth=50 src='" + filepathSmall + "' />&nbsp;&nbsp;<img width=200 heigth=100 src='" + filepath + "' />&nbsp;&nbsp;<a href='PictureStoreOperate2.aspx?num="+num.ToString()+"'>删除</a>";
                    this.pic.Text = filepath;
                    this.picsmall.Text = filepathSmall;
                }
                else
                {
                    this.picString.Text += "&nbsp;&nbsp;<img width=100 heigth=50 src='" + filepathSmall + "' />&nbsp;&nbsp;<img width=200 heigth=100 src='" + filepath + "' />&nbsp;&nbsp;<a href='PictureStoreOperate2.aspx?num=" + num.ToString() + "'>删除</a>";
                    this.pic.Text += ";" + filepath;
                    this.picsmall.Text += ";" + filepathSmall;
                }
                Session["pic" + num.ToString()] = filepath;
                Session["picSmall" + num.ToString()] = filepathSmall;

                Session["picString"] = this.picString.Text;
                Session["pic"] = this.pic.Text;
                Session["picSmall"] = this.picsmall.Text;

                Session["picNum"] = picNum;

                Session["PSGIDS"] = this.GetPSGIDs();
                Session["PictureStoreName"] = txtPictureStoreName.Text.Trim();
                Session["PictureStoreDescription"] = txtPictureStoreDescription.Text.Trim();
                Session["PictureTags"] = txtPictureStoreTag.Text.Trim();
                Session["iHairNature"] = this.ddlHairNature.SelectedItem.Value;
                Session["iHairQuantity"] = this.ddlHairQuantity.SelectedItem.Value;
                Session["iFaceStyle"] = this.ddlFaceStyle.SelectedItem.Value;
                Session["iSex"] = this.ddlSex.SelectedItem.Value;
                Session["iHairStyleClassName"] = this.ddlHairStyleClassName.SelectedItem.Value;
                Session["iTemperament"] = this.ddlTemperament.SelectedItem.Value;
                Session["iOccasion"] = this.ddlOccasion.SelectedItem.Value;
                Session["bbsUrl"] = txtBbsurl.Text.Trim();

                this.btnPicUpload.Enabled = true;
            }
        }