public string AddCompletion(decimal ctid, string content, DateTime? edate, int time, int isFileExist, string remark)
        {
            var user = GetCookieUser();
            if (user == null)
            {
                return JsonConvert.SerializeObject(new
                {
                    Message = "notlogin"
                });
            }
            try
            {
                //附件
                var file = Request.Files["fl_Completion"];
                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);

                var ds = Dal.SqlHelper.Query("select 1 from tbl_Completion where Cp_State = 0 AND Cp_CtID = " + ctid);

                if (ds.Tables[0].Rows.Count != 0)
                {
                    return JsonConvert.SerializeObject(new
                    {
                        Message = "false",
                        Content = "保存失败,该施工信息已存在竣工信息,不能重复添加"
                    });
                }

                var model = new Mo.Completion
                {
                    Cp_CtID = ctid,
                    Cp_EDate = edate,
                    Cp_ActualTime = time,
                    Cp_Content = content,
                    Cp_Remark = remark,
                    Cp_File = fileId,
                    Cp_IsFileExist = isFileExist,
                    Cp_State = 0,
                    Cp_Inputer = user.Id,
                    Cp_InputDate = DateTime.Now
                };
                if (completionBll.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"
                });
            }
        }
Exemple #2
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<PCMLib.Model.Completion> DataTableToList(DataTable dt)
 {
     List<PCMLib.Model.Completion> modelList = new List<PCMLib.Model.Completion>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         PCMLib.Model.Completion model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new PCMLib.Model.Completion();
             if (dt.Rows[n]["Cp_ID"] != null && dt.Rows[n]["Cp_ID"].ToString() != "")
             {
                 model.Cp_ID = decimal.Parse(dt.Rows[n]["Cp_ID"].ToString());
             }
             if (dt.Rows[n]["Cp_CtID"] != null && dt.Rows[n]["Cp_CtID"].ToString() != "")
             {
                 model.Cp_CtID = decimal.Parse(dt.Rows[n]["Cp_CtID"].ToString());
             }
             if (dt.Rows[n]["Cp_EDate"] != null && dt.Rows[n]["Cp_EDate"].ToString() != "")
             {
                 model.Cp_EDate = DateTime.Parse(dt.Rows[n]["Cp_EDate"].ToString());
                 model.EDate = DateTime.Parse(dt.Rows[n]["Cp_EDate"].ToString()).ToShortDateString();
             }
             if (dt.Rows[n]["Cp_ActualTime"] != null && dt.Rows[n]["Cp_ActualTime"].ToString() != "")
             {
                 model.Cp_ActualTime = int.Parse(dt.Rows[n]["Cp_ActualTime"].ToString());
             }
             if (dt.Rows[n]["Cp_Content"] != null && dt.Rows[n]["Cp_Content"].ToString() != "")
             {
                 model.Cp_Content = dt.Rows[n]["Cp_Content"].ToString();
             }
             if (dt.Rows[n]["Cp_File"] != null && dt.Rows[n]["Cp_File"].ToString() != "")
             {
                 model.Cp_File = dt.Rows[n]["Cp_File"].ToString();
             }
             if (dt.Rows[n]["Cp_State"] != null && dt.Rows[n]["Cp_State"].ToString() != "")
             {
                 model.Cp_State = int.Parse(dt.Rows[n]["Cp_State"].ToString());
             }
             if (dt.Rows[n]["Cp_IsFileExist"] != null && dt.Rows[n]["Cp_IsFileExist"].ToString() != "")
             {
                 model.Cp_IsFileExist = int.Parse(dt.Rows[n]["Cp_IsFileExist"].ToString());
             }
             if (dt.Rows[n]["Cp_Remark"] != null && dt.Rows[n]["Cp_Remark"].ToString() != "")
             {
                 model.Cp_Remark = dt.Rows[n]["Cp_Remark"].ToString();
             }
             if (dt.Rows[n]["Cp_Inputer"] != null && dt.Rows[n]["Cp_Inputer"].ToString() != "")
             {
                 model.Cp_Inputer = decimal.Parse(dt.Rows[n]["Cp_Inputer"].ToString());
             }
             if (dt.Rows[n]["Cp_InputDate"] != null && dt.Rows[n]["Cp_InputDate"].ToString() != "")
             {
                 model.Cp_InputDate = DateTime.Parse(dt.Rows[n]["Cp_InputDate"].ToString());
                 model.InputDate = DateTime.Parse(dt.Rows[n]["Cp_InputDate"].ToString()).ToShortDateString();
             }
             if (dt.Rows[n]["Cp_Editer"] != null && dt.Rows[n]["Cp_Editer"].ToString() != "")
             {
                 model.Cp_Editer = decimal.Parse(dt.Rows[n]["Cp_Editer"].ToString());
             }
             if (dt.Rows[n]["Cp_EditDate"] != null && dt.Rows[n]["Cp_EditDate"].ToString() != "")
             {
                 model.Cp_EditDate = DateTime.Parse(dt.Rows[n]["Cp_EditDate"].ToString());
                 model.EditDate = DateTime.Parse(dt.Rows[n]["Cp_EditDate"].ToString()).ToShortDateString();
             }
             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]["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]["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_Type"] != null && dt.Rows[n]["Ct_Type"].ToString() != "")
             {
                 model.Ct_Type = int.Parse(dt.Rows[n]["Ct_Type"].ToString());
             }
             if (dt.Rows[n]["Ct_Company"] != null && dt.Rows[n]["Ct_Company"].ToString() != "")
             {
                 model.Ct_Company = dt.Rows[n]["Ct_Company"].ToString();
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }