예제 #1
0
 private void fillVOData(ReactivePower vo, OleDbDataReader reader)
 {
     vo.ID = (Int32)reader["ID"];
     vo.RecReactivePowerLowerLimit = (double)reader["RecReactivePowerLowerLimit"];
     vo.InvReactivePowerLowerLimit = (double)reader["InvReactivePowerLowerLimit"];
     vo.RecReactivePowerMaxSupply = (double)reader["RecReactivePowerMaxSupply"];
     vo.RecReactivePowerMaxAbsorb = (double)reader["RecReactivePowerMaxAbsorb"];
     vo.InvReactivePowerMaxSupply = (double)reader["InvReactivePowerMaxSupply"];
     vo.InvReactivePowerMaxAbsorb = (double)reader["InvReactivePowerMaxAbsorb"];
 }
예제 #2
0
        private bool Addnew(ReactivePower vo)
        {
            using (OleDbConnection conn = CreateConnection())
            {
                //设置SQL语句
                StringBuilder sql = new StringBuilder();
                StringBuilder param = new StringBuilder();

                sql.Append("INSERT INTO ReactivePower (");
                param.Append(" VALUES (");

                sql.Append(" RecReactivePowerLowerLimit");
                param.Append("").Append(vo.RecReactivePowerLowerLimit.ToString()).Append("");

                sql.Append(", InvReactivePowerLowerLimit");
                param.Append(", ").Append(vo.InvReactivePowerLowerLimit.ToString()).Append("");

                sql.Append(", RecReactivePowerMaxSupply");
                param.Append(", ").Append(vo.RecReactivePowerMaxSupply.ToString()).Append("");

                sql.Append(", RecReactivePowerMaxAbsorb");
                param.Append(", ").Append(vo.RecReactivePowerMaxAbsorb.ToString()).Append("");

                sql.Append(", InvReactivePowerMaxSupply");
                param.Append(", ").Append(vo.InvReactivePowerMaxSupply.ToString()).Append("");

                sql.Append(", InvReactivePowerMaxAbsorb");
                param.Append(", ").Append(vo.InvReactivePowerMaxAbsorb.ToString()).Append("");

                sql.Append(")").Append(param).Append(");");

                OleDbCommand insertcmd = new OleDbCommand(sql.ToString(), conn);
                insertcmd.ExecuteNonQuery();

            }
            ResetConn();
            return true;
        }
예제 #3
0
 private bool LoadData(ReactivePower vo)
 {
     using (OleDbConnection conn = CreateConnection())
     {
         string sql = "Select * from ReactivePower ";
         if (vo.ID != -1)
         {
             sql += "where ID = " + vo.ID;
         }
         OleDbCommand myCommand = new OleDbCommand(sql, conn);
         OleDbDataReader reader = myCommand.ExecuteReader(); //执行command并得到相应的DataReader
         if (reader.Read())
         {
             fillVOData(vo, reader);
             ResetConn();
         }
         else
         {
             ResetConn();
             return false;
         }
     }
     return true;
 }
예제 #4
0
 private bool UpdateOrAddnew(ReactivePower vo)
 {
     if (!queryExists(vo))
     {
         return Addnew(vo);
     }
     else
     {
         return Update(vo);
     }
 }
예제 #5
0
        private bool Update(ReactivePower vo)
        {
            StringBuilder sql = new StringBuilder();//当时在这里定义,是为了在出现异常的时候看看我的SQL语句是否正确
            using (OleDbConnection conn = CreateConnection())
            {
                sql.Append("UPDATE ReactivePower SET RecReactivePowerLowerLimit=").Append(vo.RecReactivePowerLowerLimit);
                sql.Append(", InvReactivePowerLowerLimit=").Append(vo.InvReactivePowerLowerLimit);
                sql.Append(", RecReactivePowerMaxSupply=").Append(vo.RecReactivePowerMaxSupply);
                sql.Append(", RecReactivePowerMaxAbsorb=").Append(vo.RecReactivePowerMaxAbsorb);
                sql.Append(", InvReactivePowerMaxSupply=").Append(vo.InvReactivePowerMaxSupply);
                sql.Append(", InvReactivePowerMaxAbsorb=").Append(vo.InvReactivePowerMaxAbsorb);

                sql.Append(" WHERE ID = ").Append(vo.ID);
                //定义command对象,并执行相应的SQL语句
                OleDbCommand myCommand = new OleDbCommand(sql.ToString(), conn);
                myCommand.ExecuteNonQuery(); //执行SELECT的时候我们是用的ExecuteReader()
            }
            ResetConn();
            return true;
        }