public string AddConstruction(decimal pid, int way, decimal ccid, string company, int type, string leader, int count, string address, string content, DateTime? sdate, DateTime? edate, int time, DateTime? signDate, string remark) { var user = GetCookieUser(); if (user == null) { return JsonConvert.SerializeObject(new { Message = "notlogin" }); } try { //附件 var file = Request.Files["fl_Construction"]; var save_path = "/filecache/"; if (!Directory.Exists(Server.MapPath(save_path))) { Directory.CreateDirectory(Server.MapPath(save_path)); } if (file != null) { var ext = System.IO.Path.GetExtension(file.FileName).ToLower(); if (ext != ".zip") { return JsonConvert.SerializeObject(new { Message = "false", Content = "仅支持ZIP文件导入!" }); } } var fileId = SaveZipFiles(file, save_path); //update by kang 2015-8-19 14:49:58 允许添加多条开工信息 //if (constructionBll.GetModelList("Ct_PID = " + pid).Any()) //{ // return JsonConvert.SerializeObject(new // { // Message = "false", // Content = "该工程已存在施工信息" // }); //} var model = new Mo.Construction { Ct_PID = Convert.ToDecimal(pid), Ct_CcID = ccid, Ct_Company = company, Ct_Way = way, Ct_Type = type, Ct_Leader = leader, Ct_Count = count, Ct_Address = address, Ct_Content = content, Ct_SDate = sdate, Ct_EDate = edate, Ct_Time = time, Ct_SignDate = signDate, Ct_File = fileId, Ct_State = 0, Ct_Remark = HttpUtility.UrlDecode(Request["remark"]), Ct_Inputer = user.Id, Ct_InputDate = DateTime.Now, }; if (constructionBll.Add(model) != 0) { Dal.Log.Add("添加工程施工信息", "ADD", user.Id); return JsonConvert.SerializeObject(new { Message = "success" }); } else { return JsonConvert.SerializeObject(new { Message = "false", Content = "保存失败" }); } } catch (Exception ex) { Dal.LogError.Add(ex, user.Id); return JsonConvert.SerializeObject(new { Message = "error" }); } }
/// <summary> /// 获得数据列表 /// </summary> public List<PCMLib.Model.Construction> DataTableToList(DataTable dt) { List<PCMLib.Model.Construction> modelList = new List<PCMLib.Model.Construction>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { PCMLib.Model.Construction model; for (int n = 0; n < rowsCount; n++) { model = new PCMLib.Model.Construction(); if (dt.Rows[n]["Ct_ID"] != null && dt.Rows[n]["Ct_ID"].ToString() != "") { model.Ct_ID = decimal.Parse(dt.Rows[n]["Ct_ID"].ToString()); } if (dt.Rows[n]["Ct_PID"] != null && dt.Rows[n]["Ct_PID"].ToString() != "") { model.Ct_PID = decimal.Parse(dt.Rows[n]["Ct_PID"].ToString()); } if (dt.Rows[n]["Ct_Way"] != null && dt.Rows[n]["Ct_Way"].ToString() != "") { model.Ct_Way = int.Parse(dt.Rows[n]["Ct_Way"].ToString()); } if (dt.Rows[n]["Ct_CcID"] != null && dt.Rows[n]["Ct_CcID"].ToString() != "") { model.Ct_CcID = decimal.Parse(dt.Rows[n]["Ct_CcID"].ToString()); } if (dt.Rows[n]["Ct_Company"] != null && dt.Rows[n]["Ct_Company"].ToString() != "") { model.Ct_Company = dt.Rows[n]["Ct_Company"].ToString(); } if (dt.Rows[n]["Ct_Type"] != null && dt.Rows[n]["Ct_Type"].ToString() != "") { model.Ct_Type = int.Parse(dt.Rows[n]["Ct_Type"].ToString()); } if (dt.Rows[n]["Ct_Leader"] != null && dt.Rows[n]["Ct_Leader"].ToString() != "") { model.Ct_Leader = dt.Rows[n]["Ct_Leader"].ToString(); } if (dt.Rows[n]["Ct_Count"] != null && dt.Rows[n]["Ct_Count"].ToString() != "") { model.Ct_Count = int.Parse(dt.Rows[n]["Ct_Count"].ToString()); } if (dt.Rows[n]["Ct_Address"] != null && dt.Rows[n]["Ct_Address"].ToString() != "") { model.Ct_Address = dt.Rows[n]["Ct_Address"].ToString(); } if (dt.Rows[n]["Ct_Content"] != null && dt.Rows[n]["Ct_Content"].ToString() != "") { model.Ct_Content = dt.Rows[n]["Ct_Content"].ToString(); } if (dt.Rows[n]["Ct_SDate"] != null && dt.Rows[n]["Ct_SDate"].ToString() != "") { model.Ct_SDate = DateTime.Parse(dt.Rows[n]["Ct_SDate"].ToString()); model.SDate = Convert.ToDateTime(dt.Rows[n]["Ct_SDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Ct_EDate"] != null && dt.Rows[n]["Ct_EDate"].ToString() != "") { model.Ct_EDate = DateTime.Parse(dt.Rows[n]["Ct_EDate"].ToString()); model.EDate = Convert.ToDateTime(dt.Rows[n]["Ct_EDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Ct_Time"] != null && dt.Rows[n]["Ct_Time"].ToString() != "") { model.Ct_Time = Convert.ToInt32(dt.Rows[n]["Ct_Time"]); } if (dt.Rows[n]["Ct_ActualEDate"] != null && dt.Rows[n]["Ct_ActualEDate"].ToString() != "") { model.Ct_ActualEDate = DateTime.Parse(dt.Rows[n]["Ct_ActualEDate"].ToString()); model.ActualEDate = Convert.ToDateTime(dt.Rows[n]["Ct_ActualEDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Ct_SignDate"] != null && dt.Rows[n]["Ct_SignDate"].ToString() != "") { model.Ct_SignDate = DateTime.Parse(dt.Rows[n]["Ct_SignDate"].ToString()); model.SignDate = Convert.ToDateTime(dt.Rows[n]["Ct_SignDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Ct_CompleteRate"] != null && dt.Rows[n]["Ct_CompleteRate"].ToString() != "") { model.Ct_CompleteRate = decimal.Parse(dt.Rows[n]["Ct_CompleteRate"].ToString()); } if (dt.Rows[n]["Ct_File"] != null && dt.Rows[n]["Ct_File"].ToString() != "") { model.Ct_File = dt.Rows[n]["Ct_File"].ToString(); } if (dt.Rows[n]["Ct_Remark"] != null && dt.Rows[n]["Ct_Remark"].ToString() != "") { model.Ct_Remark = dt.Rows[n]["Ct_Remark"].ToString(); } if (dt.Rows[n]["Ct_EditDate"] != null && dt.Rows[n]["Ct_EditDate"].ToString() != "") { model.Ct_EditDate = DateTime.Parse(dt.Rows[n]["Ct_EditDate"].ToString()); model.EditDate = Convert.ToDateTime(dt.Rows[n]["Ct_EditDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Ct_Editer"] != null && dt.Rows[n]["Ct_Editer"].ToString() != "") { model.Ct_Editer = decimal.Parse(dt.Rows[n]["Ct_Editer"].ToString()); } if (dt.Rows[n]["Ct_InputDate"] != null && dt.Rows[n]["Ct_InputDate"].ToString() != "") { model.Ct_InputDate = DateTime.Parse(dt.Rows[n]["Ct_InputDate"].ToString()); model.InputDate = Convert.ToDateTime(dt.Rows[n]["Ct_InputDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Ct_Inputer"] != null && dt.Rows[n]["Ct_Inputer"].ToString() != "") { model.Ct_Inputer = decimal.Parse(dt.Rows[n]["Ct_Inputer"].ToString()); } if (dt.Rows[n]["Ct_State"] != null && dt.Rows[n]["Ct_State"].ToString() != "") { model.Ct_State = int.Parse(dt.Rows[n]["Ct_State"].ToString()); } if (dt.Rows[n]["U_RealName"] != null && dt.Rows[n]["U_RealName"].ToString() != "") { model.U_RealName = dt.Rows[n]["U_RealName"].ToString(); } if (dt.Rows[n]["P_Name"] != null && dt.Rows[n]["P_Name"].ToString() != "") { model.P_Name = dt.Rows[n]["P_Name"].ToString(); } if (dt.Rows[n]["P_No"] != null && dt.Rows[n]["P_No"].ToString() != "") { model.P_No = dt.Rows[n]["P_No"].ToString(); } if (dt.Rows[n]["Cp_ID"] != null && dt.Rows[n]["Cp_ID"].ToString() != "") { model.Cp_ID = decimal.Parse(dt.Rows[n]["Cp_ID"].ToString()); } modelList.Add(model); } } return modelList; }