/// <summary> /// 增加一条数据 /// </summary> public void Add(RelayTest.Model.ModelDEV_LOAD_INFO model) { try { Log.Info("BllDEV_LOAD_INFO->Add---START"); ConnectionOpen(); dal.SetDBAccess(GetDBAccess()); dal.Add(model); } catch (Exception ex) { Log.Error("BllDEV_LOAD_INFO->Add---FAILED", ex); throw ex; } finally { ConnectionClose(); Log.Info("BllDEV_LOAD_INFO->Add---finally"); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">相应的数据实体</param> /// <returns>真表示有记录被更新,否表示没有记录被更新</returns> public bool Update(RelayTest.Model.ModelDEV_LOAD_INFO model) { try { Log.Info("BllDEV_LOAD_INFO->Update---START"); ConnectionOpen(); dal.SetDBAccess(GetDBAccess()); return(dal.Update(model)); } catch (Exception ex) { Log.Error("BllDEV_LOAD_INFO->Update---FAILED", ex); throw ex; } finally { ConnectionClose(); Log.Info("BllDEV_LOAD_INFO->Update---finally"); } }
/// <summary> /// 得到一个对象实体 /// </summary> public RelayTest.Model.ModelDEV_LOAD_INFO GetModel(string F_LOAD_ID) { try { Log.Info("DalDEV_LOAD_INFO->GetModel---START"); StringBuilder strSql = new StringBuilder(); strSql.Append("select "); //负载柜编号 strSql.Append("F_LOAD_ID, "); //稳态电流下限 strSql.Append("F_LOAD_STABLECURRENT_FLOOR, "); //冲击电流上限 strSql.Append("F_LOAD_PULSECURRENT_CEILING, "); //冲击电流下限 strSql.Append("F_LOAD_PULSECURRENT_FLOOR, "); //负载电压上限 strSql.Append("F_LOAD_VOLTAGE_CEILING, "); //负载电压下限 strSql.Append("F_LOAD_VOLTAGE_FLOOR, "); //描述信息 strSql.Append("F_LOAD_DESCRIPTION, "); //创建时间 strSql.Append("F_CREATE_TIME, "); //操作员 strSql.Append("F_OPERATOR_ID, "); //操作时间 strSql.Append("F_OPERATIONTIME, "); //是否删除 strSql.Append("F_DEL, "); //负载柜名称 strSql.Append("F_LOAD_NAME, "); //校准编号 strSql.Append("F_LOAD_CALIBRATION, "); //负载柜位置 strSql.Append("F_LOAD_POSTION, "); //资产编号 strSql.Append("F_PROPERTY_ID, "); //负载类型 strSql.Append("F_LOAD_TYPE, "); //感性负载功率因素 strSql.Append("F_CONDUCTYLOAD_COEFFECIENCY, "); //负载电压类型 strSql.Append("F_LOAD_VOLTAGE_TYPE, "); //稳态电流上限 strSql.Append("F_LOAD_STABLECURRENT_CEILING "); strSql.Append(" from T_DEV_LOAD_INFO "); strSql.Append(" where 1=1 AND F_LOAD_ID=:F_LOAD_ID "); OracleParameter[] parameters = { new OracleParameter(":F_LOAD_ID", OracleType.VarChar, 20) }; parameters[0].Value = F_LOAD_ID; RelayTest.Model.ModelDEV_LOAD_INFO model = new RelayTest.Model.ModelDEV_LOAD_INFO(); DataSet ds = Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { model.F_LOAD_ID = ds.Tables[0].Rows[0]["F_LOAD_ID"].ToString(); if (ds.Tables[0].Rows[0]["F_LOAD_STABLECURRENT_FLOOR"].ToString() != "") { model.F_LOAD_STABLECURRENT_FLOOR = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_STABLECURRENT_FLOOR"].ToString()); } if (ds.Tables[0].Rows[0]["F_LOAD_PULSECURRENT_CEILING"].ToString() != "") { model.F_LOAD_PULSECURRENT_CEILING = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_PULSECURRENT_CEILING"].ToString()); } if (ds.Tables[0].Rows[0]["F_LOAD_PULSECURRENT_FLOOR"].ToString() != "") { model.F_LOAD_PULSECURRENT_FLOOR = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_PULSECURRENT_FLOOR"].ToString()); } if (ds.Tables[0].Rows[0]["F_LOAD_VOLTAGE_CEILING"].ToString() != "") { model.F_LOAD_VOLTAGE_CEILING = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_VOLTAGE_CEILING"].ToString()); } if (ds.Tables[0].Rows[0]["F_LOAD_VOLTAGE_FLOOR"].ToString() != "") { model.F_LOAD_VOLTAGE_FLOOR = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_VOLTAGE_FLOOR"].ToString()); } model.F_LOAD_DESCRIPTION = ds.Tables[0].Rows[0]["F_LOAD_DESCRIPTION"].ToString(); if (ds.Tables[0].Rows[0]["F_CREATE_TIME"].ToString() != "") { model.F_CREATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_CREATE_TIME"].ToString()); } model.F_OPERATOR_ID = ds.Tables[0].Rows[0]["F_OPERATOR_ID"].ToString(); if (ds.Tables[0].Rows[0]["F_OPERATIONTIME"].ToString() != "") { model.F_OPERATIONTIME = DateTime.Parse(ds.Tables[0].Rows[0]["F_OPERATIONTIME"].ToString()); } if (ds.Tables[0].Rows[0]["F_DEL"].ToString() != "") { model.F_DEL = decimal.Parse(ds.Tables[0].Rows[0]["F_DEL"].ToString()); } model.F_LOAD_NAME = ds.Tables[0].Rows[0]["F_LOAD_NAME"].ToString(); model.F_LOAD_CALIBRATION = ds.Tables[0].Rows[0]["F_LOAD_CALIBRATION"].ToString(); model.F_LOAD_POSTION = ds.Tables[0].Rows[0]["F_LOAD_POSTION"].ToString(); model.F_PROPERTY_ID = ds.Tables[0].Rows[0]["F_PROPERTY_ID"].ToString(); if (ds.Tables[0].Rows[0]["F_LOAD_TYPE"].ToString() != "") { model.F_LOAD_TYPE = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_TYPE"].ToString()); } if (ds.Tables[0].Rows[0]["F_CONDUCTYLOAD_COEFFECIENCY"].ToString() != "") { model.F_CONDUCTYLOAD_COEFFECIENCY = decimal.Parse(ds.Tables[0].Rows[0]["F_CONDUCTYLOAD_COEFFECIENCY"].ToString()); } if (ds.Tables[0].Rows[0]["F_LOAD_VOLTAGE_TYPE"].ToString() != "") { model.F_LOAD_VOLTAGE_TYPE = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_VOLTAGE_TYPE"].ToString()); } if (ds.Tables[0].Rows[0]["F_LOAD_STABLECURRENT_CEILING"].ToString() != "") { model.F_LOAD_STABLECURRENT_CEILING = decimal.Parse(ds.Tables[0].Rows[0]["F_LOAD_STABLECURRENT_CEILING"].ToString()); } return(model); } else { return(null); } } catch (Exception ex) { Log.Error("DalDEV_LOAD_INFO->GetModel---FAILED", ex); throw ex; } }
/// <summary> /// 增加一条数据 /// </summary> public void Add(RelayTest.Model.ModelDEV_LOAD_INFO model) { try { Log.Info("DalDEV_LOAD_INFO->Add---START"); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_DEV_LOAD_INFO("); //负载柜编号 strSql.Append(" F_LOAD_ID,"); //稳态电流下限 strSql.Append(" F_LOAD_STABLECURRENT_FLOOR,"); //冲击电流上限 strSql.Append(" F_LOAD_PULSECURRENT_CEILING,"); //冲击电流下限 strSql.Append(" F_LOAD_PULSECURRENT_FLOOR,"); //负载电压上限 strSql.Append(" F_LOAD_VOLTAGE_CEILING,"); //负载电压下限 strSql.Append(" F_LOAD_VOLTAGE_FLOOR,"); //描述信息 strSql.Append(" F_LOAD_DESCRIPTION,"); //创建时间 strSql.Append(" F_CREATE_TIME,"); //操作员 strSql.Append(" F_OPERATOR_ID,"); //操作时间 strSql.Append(" F_OPERATIONTIME,"); //是否删除 strSql.Append(" F_DEL,"); //负载柜名称 strSql.Append(" F_LOAD_NAME,"); //校准编号 strSql.Append(" F_LOAD_CALIBRATION,"); //负载柜位置 strSql.Append(" F_LOAD_POSTION,"); //资产编号 strSql.Append(" F_PROPERTY_ID,"); //负载类型 strSql.Append(" F_LOAD_TYPE,"); //感性负载功率因素 strSql.Append(" F_CONDUCTYLOAD_COEFFECIENCY,"); //负载电压类型 strSql.Append(" F_LOAD_VOLTAGE_TYPE,"); //稳态电流上限 strSql.Append(" F_LOAD_STABLECURRENT_CEILING"); strSql.Append(") values ("); strSql.Append(" :F_LOAD_ID,"); strSql.Append(" :F_LOAD_STABLECURRENT_FLOOR,"); strSql.Append(" :F_LOAD_PULSECURRENT_CEILING,"); strSql.Append(" :F_LOAD_PULSECURRENT_FLOOR,"); strSql.Append(" :F_LOAD_VOLTAGE_CEILING,"); strSql.Append(" :F_LOAD_VOLTAGE_FLOOR,"); strSql.Append(" :F_LOAD_DESCRIPTION,"); strSql.Append(" :F_CREATE_TIME,"); strSql.Append(" :F_OPERATOR_ID,"); strSql.Append(" :F_OPERATIONTIME,"); strSql.Append(" :F_DEL,"); strSql.Append(" :F_LOAD_NAME,"); strSql.Append(" :F_LOAD_CALIBRATION,"); strSql.Append(" :F_LOAD_POSTION,"); strSql.Append(" :F_PROPERTY_ID,"); strSql.Append(" :F_LOAD_TYPE,"); strSql.Append(" :F_CONDUCTYLOAD_COEFFECIENCY,"); strSql.Append(" :F_LOAD_VOLTAGE_TYPE,"); strSql.Append(" :F_LOAD_STABLECURRENT_CEILING"); strSql.Append(") "); OracleParameter[] parameters = { new OracleParameter(":F_LOAD_ID", OracleType.VarChar, 20), new OracleParameter(":F_LOAD_STABLECURRENT_FLOOR", OracleType.Number, 18), new OracleParameter(":F_LOAD_PULSECURRENT_CEILING", OracleType.Number, 18), new OracleParameter(":F_LOAD_PULSECURRENT_FLOOR", OracleType.Number, 18), new OracleParameter(":F_LOAD_VOLTAGE_CEILING", OracleType.Number, 18), new OracleParameter(":F_LOAD_VOLTAGE_FLOOR", OracleType.Number, 18), new OracleParameter(":F_LOAD_DESCRIPTION", OracleType.VarChar, 500), new OracleParameter(":F_CREATE_TIME", OracleType.DateTime), new OracleParameter(":F_OPERATOR_ID", OracleType.VarChar, 10), new OracleParameter(":F_OPERATIONTIME", OracleType.DateTime), new OracleParameter(":F_DEL", OracleType.Number, 4), new OracleParameter(":F_LOAD_NAME", OracleType.VarChar, 100), new OracleParameter(":F_LOAD_CALIBRATION", OracleType.VarChar, 100), new OracleParameter(":F_LOAD_POSTION", OracleType.VarChar, 100), new OracleParameter(":F_PROPERTY_ID", OracleType.VarChar, 100), new OracleParameter(":F_LOAD_TYPE", OracleType.Number, 4), new OracleParameter(":F_CONDUCTYLOAD_COEFFECIENCY", OracleType.Number, 18), new OracleParameter(":F_LOAD_VOLTAGE_TYPE", OracleType.Number, 4), new OracleParameter(":F_LOAD_STABLECURRENT_CEILING", OracleType.Number, 18) }; //负载柜编号 if (model.F_LOAD_ID == null) { parameters[0].Value = DBNull.Value; } else { parameters[0].Value = model.F_LOAD_ID; } //稳态电流下限 if (model.F_LOAD_STABLECURRENT_FLOOR == null) { parameters[1].Value = DBNull.Value; } else { parameters[1].Value = model.F_LOAD_STABLECURRENT_FLOOR; } //冲击电流上限 if (model.F_LOAD_PULSECURRENT_CEILING == null) { parameters[2].Value = DBNull.Value; } else { parameters[2].Value = model.F_LOAD_PULSECURRENT_CEILING; } //冲击电流下限 if (model.F_LOAD_PULSECURRENT_FLOOR == null) { parameters[3].Value = DBNull.Value; } else { parameters[3].Value = model.F_LOAD_PULSECURRENT_FLOOR; } //负载电压上限 if (model.F_LOAD_VOLTAGE_CEILING == null) { parameters[4].Value = DBNull.Value; } else { parameters[4].Value = model.F_LOAD_VOLTAGE_CEILING; } //负载电压下限 if (model.F_LOAD_VOLTAGE_FLOOR == null) { parameters[5].Value = DBNull.Value; } else { parameters[5].Value = model.F_LOAD_VOLTAGE_FLOOR; } //描述信息 if (model.F_LOAD_DESCRIPTION == null) { parameters[6].Value = DBNull.Value; } else { parameters[6].Value = model.F_LOAD_DESCRIPTION; } //创建时间 if (model.F_CREATE_TIME == null) { parameters[7].Value = DBNull.Value; } else { parameters[7].Value = model.F_CREATE_TIME; } //操作员 if (model.F_OPERATOR_ID == null) { parameters[8].Value = DBNull.Value; } else { parameters[8].Value = model.F_OPERATOR_ID; } //操作时间 if (model.F_OPERATIONTIME == null) { parameters[9].Value = DBNull.Value; } else { parameters[9].Value = model.F_OPERATIONTIME; } //是否删除 if (model.F_DEL == null) { parameters[10].Value = DBNull.Value; } else { parameters[10].Value = model.F_DEL; } //负载柜名称 if (model.F_LOAD_NAME == null) { parameters[11].Value = DBNull.Value; } else { parameters[11].Value = model.F_LOAD_NAME; } //校准编号 if (model.F_LOAD_CALIBRATION == null) { parameters[12].Value = DBNull.Value; } else { parameters[12].Value = model.F_LOAD_CALIBRATION; } //负载柜位置 if (model.F_LOAD_POSTION == null) { parameters[13].Value = DBNull.Value; } else { parameters[13].Value = model.F_LOAD_POSTION; } //资产编号 if (model.F_PROPERTY_ID == null) { parameters[14].Value = DBNull.Value; } else { parameters[14].Value = model.F_PROPERTY_ID; } //负载类型 if (model.F_LOAD_TYPE == null) { parameters[15].Value = DBNull.Value; } else { parameters[15].Value = model.F_LOAD_TYPE; } //感性负载功率因素 if (model.F_CONDUCTYLOAD_COEFFECIENCY == null) { parameters[16].Value = DBNull.Value; } else { parameters[16].Value = model.F_CONDUCTYLOAD_COEFFECIENCY; } //负载电压类型 if (model.F_LOAD_VOLTAGE_TYPE == null) { parameters[17].Value = DBNull.Value; } else { parameters[17].Value = model.F_LOAD_VOLTAGE_TYPE; } //稳态电流上限 if (model.F_LOAD_STABLECURRENT_CEILING == null) { parameters[18].Value = DBNull.Value; } else { parameters[18].Value = model.F_LOAD_STABLECURRENT_CEILING; } ExecuteSql(strSql.ToString(), parameters); } catch (Exception ex) { Log.Error("DalDEV_LOAD_INFO->Add---FAILED", ex); throw ex; } }
/// <summary> /// 获得数据列表 /// </summary> public List <RelayTest.Model.ModelDEV_LOAD_INFO> DataTableToList(DataTable dt) { try { Log.Info("BllDEV_LOAD_INFO->DataTableToList---START"); ConnectionOpen(); dal.SetDBAccess(GetDBAccess()); List <RelayTest.Model.ModelDEV_LOAD_INFO> modelList = new List <RelayTest.Model.ModelDEV_LOAD_INFO>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { RelayTest.Model.ModelDEV_LOAD_INFO model; for (int n = 0; n < rowsCount; n++) { model = new RelayTest.Model.ModelDEV_LOAD_INFO(); //负载柜编号 model.F_LOAD_ID = dt.Rows[n]["F_LOAD_ID"].ToString(); //稳态电流下限 if (dt.Rows[n]["F_LOAD_STABLECURRENT_FLOOR"].ToString() != "") { model.F_LOAD_STABLECURRENT_FLOOR = decimal.Parse(dt.Rows[n]["F_LOAD_STABLECURRENT_FLOOR"].ToString()); } //冲击电流上限 if (dt.Rows[n]["F_LOAD_PULSECURRENT_CEILING"].ToString() != "") { model.F_LOAD_PULSECURRENT_CEILING = decimal.Parse(dt.Rows[n]["F_LOAD_PULSECURRENT_CEILING"].ToString()); } //冲击电流下限 if (dt.Rows[n]["F_LOAD_PULSECURRENT_FLOOR"].ToString() != "") { model.F_LOAD_PULSECURRENT_FLOOR = decimal.Parse(dt.Rows[n]["F_LOAD_PULSECURRENT_FLOOR"].ToString()); } //负载电压上限 if (dt.Rows[n]["F_LOAD_VOLTAGE_CEILING"].ToString() != "") { model.F_LOAD_VOLTAGE_CEILING = decimal.Parse(dt.Rows[n]["F_LOAD_VOLTAGE_CEILING"].ToString()); } //负载电压下限 if (dt.Rows[n]["F_LOAD_VOLTAGE_FLOOR"].ToString() != "") { model.F_LOAD_VOLTAGE_FLOOR = decimal.Parse(dt.Rows[n]["F_LOAD_VOLTAGE_FLOOR"].ToString()); } //描述信息 model.F_LOAD_DESCRIPTION = dt.Rows[n]["F_LOAD_DESCRIPTION"].ToString(); //创建时间 if (dt.Rows[n]["F_CREATE_TIME"].ToString() != "") { model.F_CREATE_TIME = DateTime.Parse(dt.Rows[n]["F_CREATE_TIME"].ToString()); } //操作员 model.F_OPERATOR_ID = dt.Rows[n]["F_OPERATOR_ID"].ToString(); //操作时间 if (dt.Rows[n]["F_OPERATIONTIME"].ToString() != "") { model.F_OPERATIONTIME = DateTime.Parse(dt.Rows[n]["F_OPERATIONTIME"].ToString()); } //是否删除 if (dt.Rows[n]["F_DEL"].ToString() != "") { model.F_DEL = decimal.Parse(dt.Rows[n]["F_DEL"].ToString()); } //负载柜名称 model.F_LOAD_NAME = dt.Rows[n]["F_LOAD_NAME"].ToString(); //校准编号 model.F_LOAD_CALIBRATION = dt.Rows[n]["F_LOAD_CALIBRATION"].ToString(); //负载柜位置 model.F_LOAD_POSTION = dt.Rows[n]["F_LOAD_POSTION"].ToString(); //资产编号 model.F_PROPERTY_ID = dt.Rows[n]["F_PROPERTY_ID"].ToString(); //负载类型 if (dt.Rows[n]["F_LOAD_TYPE"].ToString() != "") { model.F_LOAD_TYPE = decimal.Parse(dt.Rows[n]["F_LOAD_TYPE"].ToString()); } //感性负载功率因素 if (dt.Rows[n]["F_CONDUCTYLOAD_COEFFECIENCY"].ToString() != "") { model.F_CONDUCTYLOAD_COEFFECIENCY = decimal.Parse(dt.Rows[n]["F_CONDUCTYLOAD_COEFFECIENCY"].ToString()); } //负载电压类型 if (dt.Rows[n]["F_LOAD_VOLTAGE_TYPE"].ToString() != "") { model.F_LOAD_VOLTAGE_TYPE = decimal.Parse(dt.Rows[n]["F_LOAD_VOLTAGE_TYPE"].ToString()); } //稳态电流上限 if (dt.Rows[n]["F_LOAD_STABLECURRENT_CEILING"].ToString() != "") { model.F_LOAD_STABLECURRENT_CEILING = decimal.Parse(dt.Rows[n]["F_LOAD_STABLECURRENT_CEILING"].ToString()); } modelList.Add(model); } } return(modelList); } catch (Exception ex) { Log.Error("BllDEV_LOAD_INFO->DataTableToList---FAILED", ex); throw ex; } finally { ConnectionClose(); Log.Info("BllDEV_LOAD_INFO->DataTableToList---finally"); } }