Пример #1
0
        /// <summary>
        /// 根据主键id查询信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static GuiGeShuMOD GetmodByid(string productNo)
        {
            GuiGeShuMOD mod = new GuiGeShuMOD();
            string sqlcommandString = "select * from GuiGeShu where productNo like '%" + productNo + "%'";

            try
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(sqlcommandString);
                if (reader.Read())
                {
                    mod.Id = Convert.ToInt32(reader["id"].ToString());
                    mod.FileUrl = reader["FileUrl"].ToString();
                    mod.ProductNo = reader["productNo"].ToString();
                    reader.Close();
                    return mod;
                }
                else
                {
                    reader.Close();
                    return null;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Save_Click(object sender, ImageClickEventArgs e)
        {
            int num = 0;
            Boolean fileOK = false;
            if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != "")
            {
                DataSet ds = GuiGeShuBLL.GetmodAll(" and productNo='" + Request.QueryString["id"] + "'");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    mod = new GuiGeShuMOD();
                    mod.ProductNo = txtProductNo.Text.Trim();
                    //上传外形图纸
                    if (fuGuigeshu.HasFile)
                    {
                        // 得到文件的后缀
                        String fileExtension =
                            System.IO.Path.GetExtension(fuGuigeshu.FileName).ToLower();
                        // 允许的文件后缀
                        String[] allowedExtensions = { ".pdf", ".PDF" };
                        // 看包含的文件是否是被允许的文件后缀
                        for (int i = 0; i < allowedExtensions.Length; i++)
                        {
                            if (fileExtension == allowedExtensions[i].ToLower())
                            {
                                // 如果是,标志位置为真
                                fileOK = true;
                            }
                        }

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

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

                                string name = fuGuigeshu.PostedFile.FileName;  //文件路径
                                FileInfo fileInfo = new FileInfo(name);
                                try
                                {
                                    fuGuigeshu.SaveAs(Server.MapPath(url));
                                    mod.FileUrl = url;
                                    fileOK = false;
                                    num = GuiGeShuBLL.Updatemod(mod);

                                }
                                catch (Exception ex)
                                {
                                    Response.Write("<script>alert('上传有误,请重新上传!');</script>");
                                }
                            }
                        }
                        else
                        {
                            Response.Write("<script>alert('只能上传pdf格式的文件!');</script>");
                            return;
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('您没有要上传的文件!');", true);
                        return;
                    }
                }
            }
            else
            {
                mod = new GuiGeShuMOD();
                mod.ProductNo = txtProductNo.Text.Trim();
                //上传外形图纸
                if (fuGuigeshu.HasFile)
                {
                    // 得到文件的后缀
                    String fileExtension =
                        System.IO.Path.GetExtension(fuGuigeshu.FileName).ToLower();
                    // 允许的文件后缀
                    String[] allowedExtensions = { ".pdf", ".PDF" };
                    // 看包含的文件是否是被允许的文件后缀
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i].ToLower())
                        {
                            // 如果是,标志位置为真
                            fileOK = true;
                        }
                    }

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

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

                            string name = fuGuigeshu.PostedFile.FileName;  //文件路径
                            FileInfo fileInfo = new FileInfo(name);
                            try
                            {
                                fuGuigeshu.SaveAs(Server.MapPath(url));
                                mod.FileUrl = url;
                                fileOK = false;
                                num = GuiGeShuBLL.Insertmod(mod);

                            }
                            catch (Exception ex)
                            {
                                Response.Write("<script>alert('上传有误,请重新上传!');</script>");
                            }
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('只能上传pdf格式的文件!');</script>");
                        return;
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('您没有要上传的文件!');", true);
                    return;
                }

            }
            if (num > 0)
            {
                //  btnPrint.Visible = true;
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "DetailsPageControl.CloseBox();alert('提交成功');')DetailsPageControl.ReflushList('orderManage/GuiGeShu.aspx');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('提交失败');", true);
            }
        }
Пример #3
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="dtomodList">数据对象</param>
 /// <returns></returns>
 public static int Updatemod(GuiGeShuMOD mod)
 {
     string sqlCommandString = "Update GuiGeShu Set FileUrl=@FileUrl where productNo=@productNo";
     SqlParameter[] arParams = new SqlParameter[2];
     arParams[0] = new SqlParameter("@FileUrl", mod.FileUrl);
     arParams[1] = new SqlParameter("@productNo", mod.ProductNo);
     return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlCommandString, arParams);
 }
Пример #4
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="dtomodList">对象</param>
        /// <returns></returns>
        public static int Insertmod(GuiGeShuMOD mod)
        {
            string sqlCommandString = "Insert Into GuiGeShu(FileUrl,productNo)Values(@FileUrl,@productNo)";
            SqlParameter[] arParams = new SqlParameter[2];
            arParams[0] = new SqlParameter("@FileUrl", mod.FileUrl);
            arParams[1] = new SqlParameter("@productNo", mod.ProductNo);

            return SqlHelper.ExecuteNonQuery(CommandType.Text, sqlCommandString, arParams);
        }