public string AddBalance(decimal ctid, decimal rate, DateTime? date, string completeContent, int? changeType, string changeContent, string remark) { var user = GetCookieUser(); if (user == null) { return JsonConvert.SerializeObject(new { Message = "notlogin" }); } try { //附件 var file = Request.Files["fl_Balance"]; 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 model = new Mo.Balance { Bl_CtID = ctid, Bl_ChangeContent = HttpUtility.UrlDecode(changeContent), Bl_ChangeType = changeType == 0 ? null : changeType, Bl_CompleteContent = HttpUtility.UrlDecode(completeContent), Bl_CompleteRate = rate, Bl_CompleteDate = date, Bl_File = fileId, Bl_State = 0, Bl_Remark = HttpUtility.UrlDecode(remark), Bl_Inputer = user.Id, Bl_InputDate = DateTime.Now, }; if (balanceBll.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.Balance> DataTableToList(DataTable dt) { var modelList = new List<Model.Balance>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { PCMLib.Model.Balance model; for (int n = 0; n < rowsCount; n++) { model = new PCMLib.Model.Balance(); if (dt.Rows[n]["Bl_ID"] != null && dt.Rows[n]["Bl_ID"].ToString() != "") { model.Bl_ID = decimal.Parse(dt.Rows[n]["Bl_ID"].ToString()); } if (dt.Rows[n]["Bl_CtID"] != null && dt.Rows[n]["Bl_CtID"].ToString() != "") { model.Bl_CtID = decimal.Parse(dt.Rows[n]["Bl_CtID"].ToString()); } if (dt.Rows[n]["Bl_CompleteRate"] != null && dt.Rows[n]["Bl_CompleteRate"].ToString() != "") { model.Bl_CompleteRate = decimal.Parse(dt.Rows[n]["Bl_CompleteRate"].ToString()); } if (dt.Rows[n]["Bl_CompleteDate"] != null && dt.Rows[n]["Bl_CompleteDate"].ToString() != "") { model.Bl_CompleteDate = DateTime.Parse(dt.Rows[n]["Bl_CompleteDate"].ToString()); model.CompleteDate = Convert.ToDateTime(dt.Rows[n]["Bl_CompleteDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Bl_CompleteContent"] != null && dt.Rows[n]["Bl_CompleteContent"].ToString() != "") { model.Bl_CompleteContent = dt.Rows[n]["Bl_CompleteContent"].ToString(); } if (dt.Rows[n]["Bl_ChangeType"] != null && dt.Rows[n]["Bl_ChangeType"].ToString() != "") { model.Bl_ChangeType = int.Parse(dt.Rows[n]["Bl_ChangeType"].ToString()); } if (dt.Rows[n]["Bl_ChangeContent"] != null && dt.Rows[n]["Bl_ChangeContent"].ToString() != "") { model.Bl_ChangeContent = dt.Rows[n]["Bl_ChangeContent"].ToString(); } if (dt.Rows[n]["Bl_File"] != null && dt.Rows[n]["Bl_File"].ToString() != "") { model.Bl_File = dt.Rows[n]["Bl_File"].ToString(); } if (dt.Rows[n]["Bl_Remark"] != null && dt.Rows[n]["Bl_Remark"].ToString() != "") { model.Bl_Remark = dt.Rows[n]["Bl_Remark"].ToString(); } if (dt.Rows[n]["Bl_State"] != null && dt.Rows[n]["Bl_State"].ToString() != "") { model.Bl_State = int.Parse(dt.Rows[n]["Bl_State"].ToString()); } if (dt.Rows[n]["Bl_Inputer"] != null && dt.Rows[n]["Bl_Inputer"].ToString() != "") { model.Bl_Inputer = decimal.Parse(dt.Rows[n]["Bl_Inputer"].ToString()); } if (dt.Rows[n]["Bl_InputDate"] != null && dt.Rows[n]["Bl_InputDate"].ToString() != "") { model.Bl_InputDate = DateTime.Parse(dt.Rows[n]["Bl_InputDate"].ToString()); model.InputDate = Convert.ToDateTime(dt.Rows[n]["Bl_InputDate"].ToString()).ToShortDateString(); } if (dt.Rows[n]["Bl_Editer"] != null && dt.Rows[n]["Bl_Editer"].ToString() != "") { model.Bl_Editer = decimal.Parse(dt.Rows[n]["Bl_Editer"].ToString()); } if (dt.Rows[n]["Bl_EditDate"] != null && dt.Rows[n]["Bl_EditDate"].ToString() != "") { model.Bl_EditDate = DateTime.Parse(dt.Rows[n]["Bl_EditDate"].ToString()); model.EditDate = Convert.ToDateTime(dt.Rows[n]["Bl_EditDate"].ToString()).ToShortDateString(); } 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]["U_RealName"] != null && dt.Rows[n]["U_RealName"].ToString() != "") { model.U_RealName = dt.Rows[n]["U_RealName"].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_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; }