/// <summary> /// 功能描述 : 添加[tblItem_Recording]表的记录 /// 创建者 : 周文卿 /// 创建日期 : 2018-01-19 /// 修改者 : /// 修改日期 : /// 修改原因 : /// </summary> /// <param name="objInsert">需要添加的实体类</param> /// <returns>返回新增记录的PK主键的值</returns> public long Insert(tblItem_Recording objInsert) { try { usp_tblItem_Recording_Insert uspInsert = new usp_tblItem_Recording_Insert(); uspInsert.ReceiveParameter(objInsert); uspInsert.ExecNoQuery(); if (uspInsert.fldAutoID > 0) { return(uspInsert.fldAutoID); } else { throw new Exception("插入新记录失败"); } } catch (DBOpenException e) { throw new InsertException("打开数据库连接失败", "RuletblItem_Recording", "Insert", objInsert.ToString()); } catch (DBPKException e) { throw new InsertException("相同的记录已经存在,违反表的唯一键约束", "RuletblItem_Recording", "Insert", objInsert.ToString()); } catch (DBQueryException e) { throw new InsertException("执行Sql语句失败", "RuletblItem_Recording", "Insert", objInsert.ToString()); } catch (Exception e) { throw new InsertException(e.Message, "RuletblItem_Recording", "Insert", objInsert.ToString()); } }
//[SupportFilter] public HttpResponseMessage UpdateItem(dynamic obj) { string result = string.Empty; try { string getjson = rule.GetJson(strLocalpath); long index = 0; JArray jsonObj = JArray.Parse(getjson); var tablename = (from x in jsonObj where x["type"].ToString() == obj.type.ToString() select x).FirstOrDefault(); RuletblItem_Recording it = new RuletblItem_Recording(); tblItem_Recording item_Recording = new tblItem_Recording(); string itemcode = "101^141^106^108^105^107"; // 如果是大气业务,并且在上述因子中,那么做除以1000的操作 if (obj.type == "eqia_r") { if (itemcode.Contains(obj.flditemcode.ToString())) { obj.fldItemValue = (double.Parse(obj.fldItemValue.ToString()) / 1000).ToString(); } } bool result2 = false; if (obj.fldRSInfo != null) { result2 = rule.UpdateitemAndRemark(obj.fldAutoid.ToString(), obj.flditemcode.ToString(), obj.fldItemValue.ToString(), tablename["tablenamepre"].ToString(), obj.fldSource.ToString(), obj.fldRSInfo.ToString(), obj.fldDate.ToString(), obj.fldRemark.ToString(), obj.fldObject.ToString()); } else { result2 = rule.Updateitem(obj.fldAutoid.ToString(), obj.flditemcode.ToString(), obj.fldItemValue.ToString(), tablename["tablenamepre"].ToString()); } if (result2) { if (obj.isitem == "y") { item_Recording.fldRange = obj.fldRSInfo + "|" + obj.flditemcode; item_Recording.fldType = obj.type.ToString(); item_Recording.fldDate = obj.fldDate.ToString(); index = it.Insert(item_Recording); } if (index > 0) { result = rule.JsonStr("ok", "", "修改成功"); } else { result = rule.JsonStr("ok", "", "记录因子值记录失败!"); } } else { result = rule.JsonStr("nodata", "无数据", ""); } } catch (Exception e) { result = rule.JsonStr("error", e.Message, ""); } return(new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }); }