/// <summary> /// 增加一条数据 /// </summary> public void Add(Entity.DEVICEINFO model) { StringBuilder strSql = new StringBuilder(); DbAPI dbHelper = new DbAPI(); strSql.Append("insert into DEVICEINFO("); strSql.Append("DEVICECODE,DEVICENAME,DEVICEUSER,DEVICETYPE,LAYTIME,ELON,ELAT,COMTYPE,STRUCTTYPE,COMARRAY,PACKNUM,RUNNINGSTATUS,POSITION,PRODUCER,MANAGER,RESERV0,RESERV1,RESERV2"); strSql.Append(") values ("); strSql.Append(":DEVICECODE,:DEVICENAME,:DEVICEUSER,:DEVICETYPE,:LAYTIME,:ELON,:ELAT,:COMTYPE,:STRUCTTYPE,:COMARRAY,:PACKNUM,:RUNNINGSTATUS,:POSITION,:PRODUCER,:MANAGER,:RESERV0,:RESERV1,:RESERV2"); strSql.Append(") "); OracleParameter[] parameters = { new OracleParameter(":DEVICECODE", OracleType.Char, 6), new OracleParameter(":DEVICENAME", OracleType.VarChar, 20), new OracleParameter(":DEVICEUSER", OracleType.VarChar, 30), new OracleParameter(":DEVICETYPE", OracleType.Number, 22), new OracleParameter(":LAYTIME", OracleType.DateTime), new OracleParameter(":ELON", OracleType.Number, 16), new OracleParameter(":ELAT", OracleType.Number, 16), new OracleParameter(":COMTYPE", OracleType.VarChar, 50), new OracleParameter(":STRUCTTYPE", OracleType.Number, 22), new OracleParameter(":COMARRAY", OracleType.Blob), new OracleParameter(":PACKNUM", OracleType.Number, 22), new OracleParameter(":RUNNINGSTATUS", OracleType.Number, 22), new OracleParameter(":POSITION", OracleType.VarChar, 20), new OracleParameter(":PRODUCER", OracleType.VarChar, 30), new OracleParameter(":MANAGER", OracleType.VarChar, 30), new OracleParameter(":RESERV0", OracleType.VarChar, 50), new OracleParameter(":RESERV1", OracleType.VarChar, 50), new OracleParameter(":RESERV2", OracleType.VarChar, 50) }; parameters[0].Value = model.DEVICECODE; parameters[1].Value = model.DEVICENAME; parameters[2].Value = model.DEVICEUSER; parameters[3].Value = model.DEVICETYPE; parameters[4].Value = model.LAYTIME; parameters[5].Value = model.ELON; parameters[6].Value = model.ELAT; parameters[7].Value = model.COMTYPE; parameters[8].Value = model.STRUCTTYPE; parameters[9].Value = model.COMARRAY; parameters[10].Value = model.PACKNUM; parameters[11].Value = model.RUNNINGSTATUS; parameters[12].Value = model.POSITION; parameters[13].Value = model.PRODUCER; parameters[14].Value = model.MANAGER; parameters[15].Value = model.RESERV0; parameters[16].Value = model.RESERV1; parameters[17].Value = model.RESERV2; dbHelper.ExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Entity.DEVICEINFO model) { StringBuilder strSql = new StringBuilder(); DbAPI dbHelper = new DbAPI(); strSql.Append("update DEVICEINFO set "); strSql.Append(" DEVICECODE = :DEVICECODE , "); strSql.Append(" DEVICENAME = :DEVICENAME , "); strSql.Append(" DEVICEUSER = :DEVICEUSER , "); strSql.Append(" DEVICETYPE = :DEVICETYPE , "); strSql.Append(" LAYTIME = :LAYTIME , "); strSql.Append(" ELON = :ELON , "); strSql.Append(" ELAT = :ELAT , "); strSql.Append(" COMTYPE = :COMTYPE , "); strSql.Append(" STRUCTTYPE = :STRUCTTYPE , "); strSql.Append(" COMARRAY = :COMARRAY , "); strSql.Append(" PACKNUM = :PACKNUM , "); strSql.Append(" RUNNINGSTATUS = :RUNNINGSTATUS , "); strSql.Append(" POSITION = :POSITION , "); strSql.Append(" PRODUCER = :PRODUCER , "); strSql.Append(" MANAGER = :MANAGER , "); strSql.Append(" RESERV0 = :RESERV0 , "); strSql.Append(" RESERV1 = :RESERV1 , "); strSql.Append(" RESERV2 = :RESERV2 "); strSql.Append(" where "); OracleParameter[] parameters = { new OracleParameter(":DEVICECODE", OracleType.Char, 6), new OracleParameter(":DEVICENAME", OracleType.VarChar, 20), new OracleParameter(":DEVICEUSER", OracleType.VarChar, 30), new OracleParameter(":DEVICETYPE", OracleType.Number, 22), new OracleParameter(":LAYTIME", OracleType.DateTime), new OracleParameter(":ELON", OracleType.Number, 16), new OracleParameter(":ELAT", OracleType.Number, 16), new OracleParameter(":COMTYPE", OracleType.VarChar, 50), new OracleParameter(":STRUCTTYPE", OracleType.Number, 22), new OracleParameter(":COMARRAY", OracleType.Blob), new OracleParameter(":PACKNUM", OracleType.Number, 22), new OracleParameter(":RUNNINGSTATUS", OracleType.Number, 22), new OracleParameter(":POSITION", OracleType.VarChar, 20), new OracleParameter(":PRODUCER", OracleType.VarChar, 30), new OracleParameter(":MANAGER", OracleType.VarChar, 30), new OracleParameter(":RESERV0", OracleType.VarChar, 50), new OracleParameter(":RESERV1", OracleType.VarChar, 50), new OracleParameter(":RESERV2", OracleType.VarChar, 50) }; parameters[0].Value = model.DEVICECODE; parameters[1].Value = model.DEVICENAME; parameters[2].Value = model.DEVICEUSER; parameters[3].Value = model.DEVICETYPE; parameters[4].Value = model.LAYTIME; parameters[5].Value = model.ELON; parameters[6].Value = model.ELAT; parameters[7].Value = model.COMTYPE; parameters[8].Value = model.STRUCTTYPE; parameters[9].Value = model.COMARRAY; parameters[10].Value = model.PACKNUM; parameters[11].Value = model.RUNNINGSTATUS; parameters[12].Value = model.POSITION; parameters[13].Value = model.PRODUCER; parameters[14].Value = model.MANAGER; parameters[15].Value = model.RESERV0; parameters[16].Value = model.RESERV1; parameters[17].Value = model.RESERV2; int rows = dbHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体DataTablesResult /// </summary> public Entity.DEVICEINFO GetModel(string deviceCode) { Entity.DEVICEINFO model = new Entity.DEVICEINFO(); StringBuilder strSql = new StringBuilder(); strSql.Append(" SELECT DI.*,DA.SEAAREA,DA.PROVINCE,DA.BAY,DA.BUREAUDEVICE,DA.LOCALDEVICE,DA.SERVICE,DA.PICTUREPATH FROM DEVICEINFO DI"); strSql.Append(" LEFT JOIN DEVICEATTACH DA ON DI.DEVICECODE=DA.DEVICECODE "); strSql.Append(" WHERE 1=1 "); List <OracleParameter> list = new List <OracleParameter>(); strSql.Append(" AND DI.DEVICECODE=:DEVICECODE "); list.Add(new OracleParameter(":DEVICECODE", deviceCode)); try { DbAPI dbHelper = new DbAPI(); DataTablesResult result = new DataTablesResult(); dbHelper.OpenConn(""); DataTable ds = dbHelper.GetDataTable(strSql.ToString(), list.ToArray()); if (ds.Rows.Count > 0) { model.DEVICECODE = ds.Rows[0]["DEVICECODE"].ToString(); model.DEVICENAME = ds.Rows[0]["DEVICENAME"].ToString(); model.DEVICEUSER = ds.Rows[0]["DEVICEUSER"].ToString(); if (ds.Rows[0]["DEVICETYPE"].ToString() != "") { model.DEVICETYPE = decimal.Parse(ds.Rows[0]["DEVICETYPE"].ToString()); } if (ds.Rows[0]["LAYTIME"].ToString() != "") { model.LAYTIME = DateTime.Parse(ds.Rows[0]["LAYTIME"].ToString()); } if (ds.Rows[0]["ELON"].ToString() != "") { model.ELON = decimal.Parse(ds.Rows[0]["ELON"].ToString()); } if (ds.Rows[0]["ELAT"].ToString() != "") { model.ELAT = decimal.Parse(ds.Rows[0]["ELAT"].ToString()); } model.COMTYPE = ds.Rows[0]["COMTYPE"].ToString(); if (ds.Rows[0]["STRUCTTYPE"].ToString() != "") { model.STRUCTTYPE = decimal.Parse(ds.Rows[0]["STRUCTTYPE"].ToString()); } if (ds.Rows[0]["COMARRAY"].ToString() != "") { model.COMARRAY = (byte[])ds.Rows[0]["COMARRAY"]; } if (ds.Rows[0]["PACKNUM"].ToString() != "") { model.PACKNUM = decimal.Parse(ds.Rows[0]["PACKNUM"].ToString()); } if (ds.Rows[0]["RUNNINGSTATUS"].ToString() != "") { model.RUNNINGSTATUS = decimal.Parse(ds.Rows[0]["RUNNINGSTATUS"].ToString()); } model.POSITION = ds.Rows[0]["POSITION"].ToString(); model.PRODUCER = ds.Rows[0]["PRODUCER"].ToString(); model.MANAGER = ds.Rows[0]["MANAGER"].ToString(); model.RESERV0 = ds.Rows[0]["RESERV0"].ToString(); model.RESERV1 = ds.Rows[0]["RESERV1"].ToString(); model.RESERV2 = ds.Rows[0]["RESERV2"].ToString(); model.SEAAREA = ds.Rows[0]["SEAAREA"].ToString(); model.SERVICE = ds.Rows[0]["SERVICE"].ToString(); model.PROVINCE = ds.Rows[0]["PROVINCE"].ToString(); model.BAY = ds.Rows[0]["BAY"].ToString(); model.BUREAUDEVICE = ds.Rows[0]["BUREAUDEVICE"].ToString(); model.LOCALDEVICE = ds.Rows[0]["LOCALDEVICE"].ToString(); model.PICTUREPATH = ds.Rows[0]["PICTUREPATH"].ToString(); } else { model = null; } dbHelper.CloseConn(); return(model); } catch (Exception ex) { LogBN.WriteLog(typeof(DEVICEINFO_BN), "GetDeviceInfo 程序段的异常" + ex); return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Entity.DEVICEINFO GetModel() { StringBuilder strSql = new StringBuilder(); DbAPI dbHelper = new DbAPI(); strSql.Append("select DEVICECODE, DEVICENAME, DEVICEUSER, DEVICETYPE, LAYTIME, ELON, ELAT, COMTYPE, STRUCTTYPE, COMARRAY, PACKNUM, RUNNINGSTATUS, POSITION, PRODUCER, MANAGER, RESERV0, RESERV1, RESERV2 "); strSql.Append(" from DEVICEINFO "); strSql.Append(" where "); OracleParameter[] parameters = { }; Entity.DEVICEINFO model = new Entity.DEVICEINFO(); DataTable ds = dbHelper.GetDataTable(strSql.ToString(), parameters); if (ds.Rows.Count > 0) { model.DEVICECODE = ds.Rows[0]["DEVICECODE"].ToString(); model.DEVICENAME = ds.Rows[0]["DEVICENAME"].ToString(); model.DEVICEUSER = ds.Rows[0]["DEVICEUSER"].ToString(); if (ds.Rows[0]["DEVICETYPE"].ToString() != "") { model.DEVICETYPE = decimal.Parse(ds.Rows[0]["DEVICETYPE"].ToString()); } if (ds.Rows[0]["LAYTIME"].ToString() != "") { model.LAYTIME = DateTime.Parse(ds.Rows[0]["LAYTIME"].ToString()); } if (ds.Rows[0]["ELON"].ToString() != "") { model.ELON = decimal.Parse(ds.Rows[0]["ELON"].ToString()); } if (ds.Rows[0]["ELAT"].ToString() != "") { model.ELAT = decimal.Parse(ds.Rows[0]["ELAT"].ToString()); } model.COMTYPE = ds.Rows[0]["COMTYPE"].ToString(); if (ds.Rows[0]["STRUCTTYPE"].ToString() != "") { model.STRUCTTYPE = decimal.Parse(ds.Rows[0]["STRUCTTYPE"].ToString()); } if (ds.Rows[0]["COMARRAY"].ToString() != "") { model.COMARRAY = (byte[])ds.Rows[0]["COMARRAY"]; } if (ds.Rows[0]["PACKNUM"].ToString() != "") { model.PACKNUM = decimal.Parse(ds.Rows[0]["PACKNUM"].ToString()); } if (ds.Rows[0]["RUNNINGSTATUS"].ToString() != "") { model.RUNNINGSTATUS = decimal.Parse(ds.Rows[0]["RUNNINGSTATUS"].ToString()); } model.POSITION = ds.Rows[0]["POSITION"].ToString(); model.PRODUCER = ds.Rows[0]["PRODUCER"].ToString(); model.MANAGER = ds.Rows[0]["MANAGER"].ToString(); model.RESERV0 = ds.Rows[0]["RESERV0"].ToString(); model.RESERV1 = ds.Rows[0]["RESERV1"].ToString(); model.RESERV2 = ds.Rows[0]["RESERV2"].ToString(); return(model); } else { return(null); } }