Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null)
         {
             int id = Convert.ToInt32(Request.QueryString["id"]);
             mod = WaiKeImgBLL.GetmodByid(id);
             if (mod != null)
             {
                 //加载客户信息
                 txtwaiKeNo.Text = mod.WaiKeNo;
                 if (mod.WaiKeImg != "")
                 {
                     imgwaiKeImg.ImageUrl = mod.WaiKeImg;
                 }
                 else
                 {
                     imgwaiKeImg.ImageUrl = "/images/nophoto.jpg";
                 }
             }
             txtwaiKeNo.Enabled = false;
             imgwaiKeImg.Visible = true;
         }
         else
         {
             imgwaiKeImg.Visible = false;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据主键id查询信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static WaiKeImgMOD GetmodByid(int id)
        {
            WaiKeImgMOD mod = new WaiKeImgMOD();
            string sqlcommandString = "select * from WaiKeImg where imgId=" + id;

            try
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(sqlcommandString);
                if (reader.Read())
                {
                    mod.ImgId = Convert.ToInt32(reader["ImgId"].ToString());
                    mod.WaiKeNo = reader["WaiKeNo"].ToString();
                    mod.WaiKeImg = reader["WaiKeImg"].ToString();
                    mod.IsModify =Convert.ToInt32( reader["IsModify"].ToString());
                }
                reader.Close();
                return mod;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 3
0
    /// <summary>
    /// 添加
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Save_Click(object sender, ImageClickEventArgs e)
    {
        int num = 0;

        if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null)
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            mod = WaiKeImgBLL.GetmodByid(id);
            Boolean fileOK = false;
            //上传外形图纸
            if (fuwaiKeImg.HasFile)
            {
                // 得到文件的后缀
                String fileExtension =
                    System.IO.Path.GetExtension(fuwaiKeImg.FileName).ToLower();
                // 允许的文件后缀
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                // 看包含的文件是否是被允许的文件后缀
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        // 如果是,标志位置为真
                        fileOK = true;
                    }
                }

                if (fileOK)
                {
                    string url = "~/fileUpload/" + fuwaiKeImg.FileName;

                    if (fuwaiKeImg.HasFile)
                    {
                        string fileType = fuwaiKeImg.PostedFile.ContentType;

                        string name = fuwaiKeImg.PostedFile.FileName;  //文件路径
                        FileInfo fileInfo = new FileInfo(name);
                        try
                        {
                            fuwaiKeImg.SaveAs(Server.MapPath(url));
                            mod.WaiKeImg = url;
                            mod.IsModify = 1;
                            fileOK = false;

                        }
                        catch (Exception ex)
                        {
                            Response.Write("<script>alert('上传有误,请重新上传!');</script>");
                        }
                    }
                }
                else
                {
                    Response.Write("<script>alert('只能上传gif,png,jpeg,jpg格式的文件!');</script>");
                    return;
                }
            }
            num = WaiKeImgBLL.Updatemod(mod);
        }
        else
        {
            mod = new WaiKeImgMOD();
            mod.IsModify = 0;
            mod.WaiKeNo = txtwaiKeNo.Text.Trim();
            Boolean fileOK = false;
            //上传外形图纸
            if (fuwaiKeImg.HasFile)
            {
                // 得到文件的后缀
                String fileExtension =
                    System.IO.Path.GetExtension(fuwaiKeImg.FileName).ToLower();
                // 允许的文件后缀
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
                // 看包含的文件是否是被允许的文件后缀
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        // 如果是,标志位置为真
                        fileOK = true;
                    }
                }

                if (fileOK)
                {
                    string url = "~/fileUpload/" + fuwaiKeImg.FileName;

                    if (fuwaiKeImg.HasFile)
                    {
                        string fileType = fuwaiKeImg.PostedFile.ContentType;

                        string name = fuwaiKeImg.PostedFile.FileName;  //文件路径
                        FileInfo fileInfo = new FileInfo(name);
                        try
                        {
                            fuwaiKeImg.SaveAs(Server.MapPath(url));
                            mod.WaiKeImg = url;
                            fileOK = false;
                        }
                        catch (Exception ex)
                        {
                            Response.Write("<script>alert('上传有误,请重新上传!');</script>");
                        }
                    }
                }
                else
                {
                    Response.Write("<script>alert('只能上传gif,png,jpeg,jpg格式的文件!');</script>");
                    return;
                }
            }
            else
            {
                mod.WaiKeImg = "";
            }
            num = WaiKeImgBLL.Insertmod(mod);
        }
        if (num > 0)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "DetailsPageControl.CloseBox();alert('提交成功');DetailsPageControl.ReflushList('ProductManage/WaiKeImgManage.aspx');", true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('提交失败');", true);
        }
    }
Ejemplo n.º 4
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="dtomodList">数据对象</param>
 /// <returns></returns>
 public static int Updatemod(WaiKeImgMOD mod)
 {
     string sqlCommandString = "Update WaiKeImg Set waiKeImg=@waiKeImg,isModify=@isModify Where imgId=@imgId";
     SqlParameter[] arParams = new SqlParameter[3];
     arParams[0] = new SqlParameter("@imgId", mod.ImgId);
     arParams[1] = new SqlParameter("@waiKeImg", mod.WaiKeImg);
     arParams[2] = new SqlParameter("@isModify", mod.IsModify);
     return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlCommandString, arParams);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="dtomodList">对象</param>
        /// <returns></returns>
        public static int Insertmod(WaiKeImgMOD mod)
        {
            string sqlCommandString =string.Format(
                @" IF not exists(select 1 from WaiKeImg where waiKeNo='{0}')
                      BEGIN
                      Insert Into WaiKeImg(waiKeNo,waiKeImg,isModify)Values(@waiKeNo,@waiKeImg,@isModify)
                      END ",mod.WaiKeNo);
            SqlParameter[] arParams = new SqlParameter[3];
            arParams[0] = new SqlParameter("@waiKeNo", mod.WaiKeNo);
            arParams[1] = new SqlParameter("@waiKeImg", mod.WaiKeImg);
            arParams[2] = new SqlParameter("@isModify", mod.IsModify);

            return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlCommandString, arParams);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="dtomodList">数据对象</param>
 /// <returns></returns>
 public static int Updatemod(WaiKeImgMOD mod)
 {
     return WaiKeImgDAO.Updatemod(mod);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="dtomodList">对象</param>
 /// <returns></returns>
 public static int Insertmod(WaiKeImgMOD mod)
 {
     return WaiKeImgDAO.Insertmod(mod);
 }