コード例 #1
0
 public void BingindUiData(LineResistance vo)
 {
     textBox1.Text = StringUtil.Zero2Text(vo.DoublePoleMaxResistance);
     textBox2.Text = StringUtil.Zero2Text(vo.DoublePoleMinResistance);
     textBox4.Text = StringUtil.Zero2Text(vo.GroundReturnMaxResistance);
     textBox3.Text = StringUtil.Zero2Text(vo.GroundReturnMinResistance);
     textBox6.Text = StringUtil.Zero2Text(vo.MetalReturnMaxResistance);
     textBox5.Text = StringUtil.Zero2Text(vo.MetalReturnMinResistance);
 }
コード例 #2
0
 private void fillVOData(LineResistance vo, OleDbDataReader reader)
 {
     vo.ID = (Int32)reader["ID"];
     vo.DoublePoleMaxResistance = (double)reader["DoublePoleMaxResistance"];
     vo.DoublePoleMinResistance = (double)reader["DoublePoleMinResistance"];
     vo.GroundReturnMaxResistance = (double)reader["GroundReturnMaxResistance"];
     vo.GroundReturnMinResistance = (double)reader["GroundReturnMinResistance"];
     vo.MetalReturnMaxResistance = (double)reader["MetalReturnMaxResistance"];
     vo.MetalReturnMinResistance = (double)reader["MetalReturnMinResistance"];
 }
コード例 #3
0
 public void fillVoData(LineResistance vo)
 {
     if (textBox1.Text != string.Empty)
         vo.DoublePoleMaxResistance = Convert.ToDouble(textBox1.Text);
     if (textBox1.Text != string.Empty)
         vo.DoublePoleMinResistance = Convert.ToDouble(textBox2.Text);
     if (textBox4.Text != string.Empty)
         vo.GroundReturnMaxResistance = Convert.ToDouble(textBox4.Text);
     if (textBox3.Text != string.Empty)
         vo.GroundReturnMinResistance = Convert.ToDouble(textBox3.Text);
     if (textBox6.Text != string.Empty)
         vo.MetalReturnMaxResistance = Convert.ToDouble(textBox6.Text);
     if (textBox5.Text != string.Empty)
         vo.MetalReturnMinResistance = Convert.ToDouble(textBox5.Text);
 }
コード例 #4
0
        private bool Addnew(LineResistance vo)
        {
            using (OleDbConnection conn = CreateConnection())
            {
                //设置SQL语句
                StringBuilder sql = new StringBuilder();
                StringBuilder param = new StringBuilder();

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

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

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

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

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

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

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

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

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

            }
            ResetConn();
            return true;
        }
コード例 #5
0
 private bool LoadData(LineResistance vo)
 {
     using (OleDbConnection conn = CreateConnection())
     {
         string sql = "Select * from LineResistance ";
         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;
 }
コード例 #6
0
 private bool UpdateOrAddnew(LineResistance vo)
 {
     if (!queryExists(vo))
     {
         return Addnew(vo);
     }
     else
     {
         return Update(vo);
     }
 }
コード例 #7
0
        private bool Update(LineResistance vo)
        {
            StringBuilder sql = new StringBuilder();//当时在这里定义,是为了在出现异常的时候看看我的SQL语句是否正确
            using (OleDbConnection conn = CreateConnection())
            {
                sql.Append("UPDATE LineResistance SET DoublePoleMaxResistance=").Append(vo.DoublePoleMaxResistance);
                sql.Append(", DoublePoleMinResistance=").Append(vo.DoublePoleMinResistance);
                sql.Append(", GroundReturnMaxResistance=").Append(vo.GroundReturnMaxResistance);
                sql.Append(", GroundReturnMinResistance=").Append(vo.GroundReturnMinResistance);
                sql.Append(", MetalReturnMaxResistance=").Append(vo.MetalReturnMaxResistance);
                sql.Append(", MetalReturnMinResistance=").Append(vo.MetalReturnMinResistance);

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