Ejemplo n.º 1
0
        void DataBindText(string drugid, int itype)
        {
            cSourceImage csimage = new cSourceImage();
            DataTable    dt      = csimage.GetDTbyNum(drugid, itype);

            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //string cid = Request.Params.Keys[0].ToString();
            //string strid = Request.QueryString[cid];

            //string strid = Request.QueryString["imgid"];

            string       strid   = Request.Params["imgid"];
            cSourceImage csimage = new cSourceImage();
            string       imgPath = csimage.GetimgPath(Convert.ToInt32(strid));

            Image1.ImageUrl = imgPath;
        }
Ejemplo n.º 3
0
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            cSourceImage csimage = new cSourceImage();

            if (e.CommandName == "del")
            {
                int iimgid = Convert.ToInt32(e.CommandArgument);

                string         DeleteCommand = "DELETE FROM [Image] WHERE [imgid] = @imgid";
                SqlParameter[] par           = new SqlParameter[1];

                int val = -10;
                par[0] = new SqlParameter("@imgid", SqlDbType.Int); par[0].Value = iimgid;
                try
                {
                    //
                    string picPath = csimage.GetimgPath(iimgid);
                    val = csimage.ModiImage(DeleteCommand, par);
                    if (picPath != "")
                    {
                        string savePath = Server.MapPath(picPath); //必须经过这一步操作才能变成有效路径
                        if (System.IO.File.Exists(savePath))       //先判断文件是否存在,再执行操作
                        {
                            System.IO.File.Delete(savePath);
                        }
                    }
                    if (val > 0)
                    {
                        Script.AjaxAlert(DataList1, "恭喜您,图片删除成功!");
                    }

                    //删除之后要重新绑定
                    string drugid = hid_drugid.Value;
                    int    itype  = Convert.ToInt32(DropDownList1.SelectedItem.Value);
                    DataBindText(drugid, itype);
                    CharTextRequired1.TextValue = "";
                }
                catch
                { }
            }
            else if (e.CommandName == "detail")
            {
                //如果是点击原图按钮则要放大图像
                //  Response.Redirect("ResponseImage.aspx", "_blank", "menubar=0,width=200,height=200");
                int gimgid = Convert.ToInt32(e.CommandArgument);

                string str = "<script languge='javascript'> window.open('ResponseImage.aspx?imgid=" + gimgid + "','','height = 600,width = 800,top = 0,left = 0,toobar =no,menubar=no,scrollbars=yes,resizable=yes,location = no,status=no')</script>";
                Response.Write(str);
            }
        }
Ejemplo n.º 4
0
        protected int ExcuteInsert()
        {
            int    val           = -10;
            string InsertCommand = "INSERT INTO [Image] ([drugid], [imagename], [itype], [inum], [filepath], [ifilesize], [filetype], [filename], [imagebak1], [imagebak2]) VALUES (@drugid, @imagename, @itype, @inum, @filepath, @ifilesize, @filetype, @filename, @imagebak1, @imagebak2)";

            SqlParameter[] par     = new SqlParameter[10];
            int            idrugid = 0;
            int            ginum   = 0;
            cSourceImage   csimage = new cSourceImage();

            if (Session["drugid"] != null)
            {
                hid_drugid.Value = Session["drugid"].ToString();
                idrugid          = Convert.ToInt32(Session["drugid"].ToString());
                ginum            = csimage.GetImageNum(hid_drugid.Value, DropDownList1.SelectedIndex);
            }
            else
            {
                //这个地方还需要再次考虑一下,是否要弹出一个窗口
                Response.Redirect("../Admin/AdWeb/APassport.aspx");
            }

            par[0] = new SqlParameter("@drugid", SqlDbType.Int);            par[0].Value = Convert.ToInt32(hid_drugid.Value);
            par[1] = new SqlParameter("@imagename", SqlDbType.NVarChar, 40); par[1].Value = CharTextRequired1.TextValue;
            par[2] = new SqlParameter("@itype", SqlDbType.Int); par[2].Value = DropDownList1.SelectedIndex;

            par[3] = new SqlParameter("@inum", SqlDbType.Int); par[3].Value = ginum;
            par[4] = new SqlParameter("@filepath", SqlDbType.NVarChar, 200); par[4].Value = l1.Text;

            //以下5项都可以不要
            par[5] = new SqlParameter("@ifilesize", SqlDbType.BigInt); par[5].Value = 0;
            par[6] = new SqlParameter("@filetype", SqlDbType.NVarChar, 40); par[6].Value = "";
            par[7] = new SqlParameter("@filename", SqlDbType.NVarChar, 100); par[7].Value = "";
            par[8] = new SqlParameter("@imagebak1", SqlDbType.NVarChar, 40); par[8].Value = "";
            par[9] = new SqlParameter("@imagebak2", SqlDbType.NVarChar, 40); par[9].Value = "";

            try
            {
                val = csimage.ModiImage(InsertCommand, par);
            }
            catch
            { }



            return(val);
        }