public HttpResponseMessage ModifyContractInf(YH_ContractModel model) { HttpRequestBase request = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request; int success = 0; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); string[] fileClass = model.uploadpanelValue; List <FileUploadClass> list = new List <FileUploadClass>(); if (fileClass != null && fileClass.Length > 0) { foreach (var item in fileClass) { FileUploadClass file = new FileUploadClass(); JObject jo = new JObject(); jo = (JObject)JsonConvert.DeserializeObject(item); file.OriginalPath = jo["OriginalPath"] == null ? "" : jo["OriginalPath"].ToString(); file.OriginalName = jo["OriginalName"] == null ? "" : jo["OriginalName"].ToString(); file.OriginalType = jo["OriginalType"] == null ? "" : jo["OriginalType"].ToString(); file.size = jo["size"] == null ? 0 : (double)jo["size"]; list.Add(file); } } int result = bll.ModifyContractInf(model, list); if (success > 0) { response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html"); } return(response); }
public object AddContractApi(YH_ContractModel model) { try { int success = 1;//bll.AddContract(model); if (success > 0) { return(new { msg = "上报成功", resCode = 1 }); } else { return(new { msg = "json数据不正确", resCode = 0 }); } } catch (Exception) { return(new { msg = "json数据不正确", resCode = 0 }); } }
public HttpResponseMessage AddContract(YH_ContractModel model) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); HttpRequestBase request = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request; string[] fileClass = model.uploadpanelValue; List <FileClass> list = new List <FileClass>(); if (fileClass != null && fileClass.Length > 0) { foreach (var item in fileClass) { FileClass file = new FileClass(); JObject jo = new JObject(); jo = (JObject)JsonConvert.DeserializeObject(item); file.OriginalPath = jo["OriginalPath"] == null ? "" : jo["OriginalPath"].ToString(); file.OriginalName = jo["OriginalName"] == null ? "" : jo["OriginalName"].ToString(); file.OriginalType = jo["OriginalType"] == null ? "" : jo["OriginalType"].ToString(); file.size = jo["size"] == null ? 0 : (double)jo["size"]; list.Add(file); } } if (!string.IsNullOrEmpty(request.Form["userid"])) { model.createuserid = Convert.ToInt32(request.Form["userid"]); } model.contactendtime = model.endtime; model.currentmoney = model.summoney; int success = bll.AddContract(model, list); if (success > 0) { response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html"); } else { response.Content = new StringContent("{\"success\":false}", Encoding.GetEncoding("UTF-8"), "text/html"); } return(response); }
public int ModifyContractInf(YH_ContractModel model, List <FileUploadClass> list) { return(dal.ModifyContractInf(model, list)); }
/// <summary> /// 添加养护日志 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddContract(YH_ContractModel model, List <FileClass> list) { return(dal.AddContract(model, list)); }
public int ModifyContractInf(YH_ContractModel model, List <FileUploadClass> list) { bool info = false, file = false; using (Entities db = new Entities()) { yh_contracts bags_model = db.yh_contracts.FirstOrDefault(a => a.contractid == model.contractid); if (bags_model != null) { bags_model.contractname = model.contractname; bags_model.patrolexplain = model.patrolexplain; bags_model.contractnum = model.contractnum; bags_model.jfdw = model.jfdw; bags_model.jfdb = model.jfdb; bags_model.yfdw = model.yfdw; bags_model.yfdb = model.yfdb; bags_model.jldw = model.jldw; bags_model.starttime = model.starttime; bags_model.endtime = model.endtime; bags_model.signdate = model.signdate; bags_model.summoney = model.summoney; bags_model.htzxzt = model.htzxzt; bags_model.currentmoney = model.currentmoney; bags_model.contactendtime = model.contactendtime; bags_model.contacttype = model.contacttype; bags_model.contracttype = model.contracttype; bags_model.yhmoney = model.yhmoney; bags_model.patrolemoney = model.patrolemoney; if (db.SaveChanges() > 0) { info = true; } } foreach (var item in list) { yh_files filemodel = new yh_files(); filemodel.filesource = 1; //1合同2日志3单位 filemodel.filename = item.OriginalName; filemodel.filepath = item.OriginalPath; filemodel.filesize = item.size; filemodel.filetype = item.OriginalType; filemodel.sourceid = bags_model.contractid; db.yh_files.Add(filemodel); } if (db.SaveChanges() > 0) { file = true; } if (info && file) { return(1); } else { return(0); } } }
/// <summary> /// 查看养护合同详情 /// </summary> /// <param name="contractid"></param> /// <returns></returns> public YH_ContractModel GetContractModel(int contractid) { using (Entities db = new Entities()) { #region linq //IQueryable<YH_ContractModel> queryable = from a in db.yh_contracts // join b_join in db.base_zds on a.contacttype equals b_join.zd_id into btmp // from b in btmp.DefaultIfEmpty() // join c_join in db.base_zds on a.contacttype equals c_join.zd_id into ctmp // from c in ctmp.DefaultIfEmpty() // join d_join in db.base_users on a.createuserid equals d_join.id into dtmp // from d in dtmp.DefaultIfEmpty() // where b.zd_type == "type_yhht_yhnr" && a.contractid == contractid && c.zd_type == "type_yhht_yhht" // select new YH_ContractModel // { // contractid = a.contractid, // contractname = a.contractname, // contacttype = a.contacttype, // contacttypename = b == null ? "" : b.zd_name, // jfdw = a.jfdw, // jfdb = a.jfdb, // yfdw = a.yfdw, // yfdb = a.yfdb, // htzxzt = a.htzxzt, // createtime = a.createtime, // patrolexplain = a.patrolexplain, // starttime = a.starttime, // endtime = a.endtime, // signdate = a.signdate, // summoney = a.summoney, // currentmoney = a.currentmoney, // contactendtime = a.contactendtime, // contracttypename = c == null ? "" : c.zd_name, // contracttype = a.contracttype, // createusername = d == null ? "" : d.displayname, // createuserid = a.createuserid, // }; #endregion string sql = string.Format(@"select yhcon.*, a.zd_name contacttypename,b.zd_name contracttypename,users.displayname createusername from yh_contracts yhcon left join (select * from yh_files fi where fi.filetype=1) as file on yhcon.contractid= file.sourceid left join (select * from base_zds zdsOne where zdsOne.zd_type='type_yhht_yhnr') as a on yhcon.contacttype=a.zd_id left join (select * from base_zds zdsOne where zdsOne.zd_type='type_yhht_yhht') as b on yhcon.contracttype=b.zd_id left join base_users users on yhcon.createuserid=users.id where yhcon.contractid=" + contractid); IEnumerable <YH_ContractModel> queryable = db.Database.SqlQuery <YH_ContractModel>(sql); YH_FileDAL dal = new YH_FileDAL(); YH_ContractModel model = queryable.FirstOrDefault(); if (model != null) { if (model.htzxzt == 1) { model.contractstate = "执行中"; } else if (model.htzxzt == 2) { model.contractstate = "已执行"; } else if (model.htzxzt == 3) { model.contractstate = "已停止"; } model.filelist = dal.GetFileList(1, contractid); } return(model); } }
/// <summary> /// 添加养护合同 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddContract(YH_ContractModel model, List <FileClass> list) { bool info = false, file = false; using (Entities db = new Entities()) { yh_contracts yhmodel = new yh_contracts(); yhmodel.contractid = model.contractid; yhmodel.contractname = model.contractname; yhmodel.patrolexplain = model.patrolexplain; yhmodel.contractnum = model.contractnum; yhmodel.jfdw = model.jfdw; yhmodel.jfdb = model.jfdb; yhmodel.yfdw = model.yfdw; yhmodel.yfdb = model.yfdb; yhmodel.jldw = model.jldw; yhmodel.starttime = model.starttime; yhmodel.endtime = model.endtime; yhmodel.signdate = model.signdate; yhmodel.summoney = model.summoney; yhmodel.htzxzt = model.htzxzt; yhmodel.currentmoney = model.currentmoney; yhmodel.contactendtime = model.contactendtime; yhmodel.contacttype = model.contacttype; yhmodel.contracttype = model.contracttype; yhmodel.yhmoney = model.yhmoney; yhmodel.patrolemoney = model.patrolemoney; yhmodel.createuserid = model.createuserid; yhmodel.createtime = DateTime.Now; db.yh_contracts.Add(yhmodel); if (db.SaveChanges() > 0) { info = true; } foreach (var item in list) { yh_files filemodel = new yh_files(); filemodel.filesource = 1; //1合同 2日志 3单位 filemodel.filename = item.OriginalName; filemodel.filepath = item.OriginalPath; filemodel.filesize = item.size; filemodel.filetype = item.OriginalType; filemodel.sourceid = yhmodel.contractid; db.yh_files.Add(filemodel); } if (db.SaveChanges() > 0) { file = true; } if (info || (info && file)) { return(1); } else { return(0); } } }