市长热线演示版

shangchuanAdd.aspx.cs 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.IO;
  8. using System.Text.RegularExpressions;
  9. namespace HySoft.BaseCallCenter.Web.workordermanage.workorder
  10. {
  11. public partial class shangchuanAdd : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. try
  16. {
  17. if (Request.Files["FileData"] != null)
  18. {
  19. HttpPostedFile file = Request.Files["FileData"];
  20. //string s = HttpContext.Current.Server.MapPath(Request["folder"]) + "\\";
  21. string year = DateTime.Today.Year.ToString();
  22. string month = DateTime.Today.Month.ToString();
  23. string day = DateTime.Today.Day.ToString();
  24. string path = @"\fujian\" + year + @"\" + month + @"\" + day + @"\";
  25. string uploadpath = @"D:" + path;
  26. string name = "(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")" + file.FileName;
  27. if (file != null)
  28. {
  29. if (!Directory.Exists(uploadpath))
  30. {
  31. Directory.CreateDirectory(uploadpath);
  32. }
  33. file.SaveAs(uploadpath + name);
  34. Response.Write("1");
  35. }
  36. else
  37. {
  38. Response.Write("0");
  39. }
  40. Model.T_Wo_WorkOrderFiles model_file = new Model.T_Wo_WorkOrderFiles();
  41. BLL.T_Wo_WorkOrderFiles bll_file = new BLL.T_Wo_WorkOrderFiles();
  42. Common.LoginUser user = new Common.LoginUser(this.Context);
  43. model_file.F_NAME = file.FileName;
  44. model_file.F_PATH = path + name;
  45. model_file.F_WORKORDERID = 0;
  46. model_file.F_DES = "";
  47. model_file.F_TYPE = "4";
  48. model_file.F_SIZE = file.ContentLength;
  49. model_file.F_UPLOADSTATE = 1;
  50. model_file.F_USERID = user.UserID;
  51. model_file.F_UPLOADDATE = DateTime.Now;
  52. bll_file.Add(model_file);
  53. string id = DBUtility.DbHelperSQL.MaxID("F_FILEID", "T_Wo_WorkOrderFiles").ToString();
  54. if (Session["orderwenjian"] != null)
  55. {
  56. Session["orderwenjian"] = Session["orderwenjian"] + id + "xgxidname" + file.FileName + "xgxjw";
  57. }
  58. }
  59. }
  60. catch { }
  61. }
  62. }
  63. }