Esempio n. 1
0
 private void ShowInfo(int ID)
 {
     WebDemo.BLL.WebDemo.ReadNowData   bll   = new WebDemo.BLL.WebDemo.ReadNowData();
     WebDemo.Model.WebDemo.ReadNowData model = bll.GetModel(ID);
     this.lblID.Text                = model.ID.ToString();
     this.lblMeterID.Text           = model.MeterID.ToString();
     this.lblReadNumber.Text        = model.ReadNumber.ToString();
     this.lblValveState.Text        = model.ValveState.ToString();
     this.lblAttackState.Text       = model.AttackState.ToString();
     this.lblVoltage.Text           = model.Voltage.ToString();
     this.lblReadDate.Text          = model.ReadDate.ToString();
     this.lblInstantNumber.Text     = model.InstantNumber.ToString();
     this.lblPileNumber.Text        = model.PileNumber.ToString();
     this.lblWatertemp.Text         = model.Watertemp.ToString();
     this.lblBackWatertemp.Text     = model.BackWatertemp.ToString();
     this.lblWorkDate.Text          = model.WorkDate.ToString();
     this.lblFactDate.Text          = model.FactDate;
     this.lblBatteryState.Text      = model.BatteryState.ToString();
     this.lblWarning.Text           = model.Warning.ToString();
     this.lblOldFreezeNumber.Text   = model.OldFreezeNumber.ToString();
     this.lblMegabit.Text           = model.Megabit.ToString();
     this.lblUseState.Text          = model.UseState.ToString();
     this.lblControlValveDate.Text  = model.ControlValveDate.ToString();
     this.lblSyncFlag.Text          = model.SyncFlag.ToString();
     this.lblPriceSetNo.Text        = model.PriceSetNo.ToString();
     this.lblCollectorReadDate.Text = model.CollectorReadDate.ToString();
     this.lblMeterStatusString.Text = model.MeterStatusString;
     this.lblRemnant.Text           = model.Remnant.ToString();
 }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.ReadNowData GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,MeterID,ReadNumber,ValveState,AttackState,Voltage,ReadDate,InstantNumber,PileNumber,Watertemp,BackWatertemp,WorkDate,FactDate,BatteryState,Warning,OldFreezeNumber,Megabit,UseState,ControlValveDate,SyncFlag,PriceSetNo,CollectorReadDate,MeterStatusString,Remnant from ReadNowData ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            WebDemo.Model.WebDemo.ReadNowData model = new WebDemo.Model.WebDemo.ReadNowData();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtMeterID.Text))
            {
                strErr += "MeterID格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtReadNumber.Text))
            {
                strErr += "ReadNumber格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtValveState.Text))
            {
                strErr += "ValveState格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtAttackState.Text))
            {
                strErr += "AttackState格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtVoltage.Text))
            {
                strErr += "Voltage格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtReadDate.Text))
            {
                strErr += "ReadDate格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtInstantNumber.Text))
            {
                strErr += "InstantNumber格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtPileNumber.Text))
            {
                strErr += "PileNumber格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtWatertemp.Text))
            {
                strErr += "Watertemp格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtBackWatertemp.Text))
            {
                strErr += "BackWatertemp格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtWorkDate.Text))
            {
                strErr += "WorkDate格式错误!\\n";
            }
            if (this.txtFactDate.Text.Trim().Length == 0)
            {
                strErr += "FactDate不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtBatteryState.Text))
            {
                strErr += "BatteryState格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtWarning.Text))
            {
                strErr += "Warning格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtOldFreezeNumber.Text))
            {
                strErr += "OldFreezeNumber格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtMegabit.Text))
            {
                strErr += "Megabit格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtUseState.Text))
            {
                strErr += "UseState格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtControlValveDate.Text))
            {
                strErr += "ControlValveDate格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtSyncFlag.Text))
            {
                strErr += "SyncFlag格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtPriceSetNo.Text))
            {
                strErr += "PriceSetNo格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtCollectorReadDate.Text))
            {
                strErr += "CollectorReadDate格式错误!\\n";
            }
            if (this.txtMeterStatusString.Text.Trim().Length == 0)
            {
                strErr += "MeterStatusString不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtRemnant.Text))
            {
                strErr += "Remnant格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID                = int.Parse(this.lblID.Text);
            int      MeterID           = int.Parse(this.txtMeterID.Text);
            decimal  ReadNumber        = decimal.Parse(this.txtReadNumber.Text);
            int      ValveState        = int.Parse(this.txtValveState.Text);
            int      AttackState       = int.Parse(this.txtAttackState.Text);
            decimal  Voltage           = decimal.Parse(this.txtVoltage.Text);
            DateTime ReadDate          = DateTime.Parse(this.txtReadDate.Text);
            decimal  InstantNumber     = decimal.Parse(this.txtInstantNumber.Text);
            decimal  PileNumber        = decimal.Parse(this.txtPileNumber.Text);
            decimal  Watertemp         = decimal.Parse(this.txtWatertemp.Text);
            decimal  BackWatertemp     = decimal.Parse(this.txtBackWatertemp.Text);
            int      WorkDate          = int.Parse(this.txtWorkDate.Text);
            string   FactDate          = this.txtFactDate.Text;
            int      BatteryState      = int.Parse(this.txtBatteryState.Text);
            int      Warning           = int.Parse(this.txtWarning.Text);
            decimal  OldFreezeNumber   = decimal.Parse(this.txtOldFreezeNumber.Text);
            int      Megabit           = int.Parse(this.txtMegabit.Text);
            int      UseState          = int.Parse(this.txtUseState.Text);
            DateTime ControlValveDate  = DateTime.Parse(this.txtControlValveDate.Text);
            int      SyncFlag          = int.Parse(this.txtSyncFlag.Text);
            int      PriceSetNo        = int.Parse(this.txtPriceSetNo.Text);
            DateTime CollectorReadDate = DateTime.Parse(this.txtCollectorReadDate.Text);
            string   MeterStatusString = this.txtMeterStatusString.Text;
            decimal  Remnant           = decimal.Parse(this.txtRemnant.Text);


            WebDemo.Model.WebDemo.ReadNowData model = new WebDemo.Model.WebDemo.ReadNowData();
            model.ID                = ID;
            model.MeterID           = MeterID;
            model.ReadNumber        = ReadNumber;
            model.ValveState        = ValveState;
            model.AttackState       = AttackState;
            model.Voltage           = Voltage;
            model.ReadDate          = ReadDate;
            model.InstantNumber     = InstantNumber;
            model.PileNumber        = PileNumber;
            model.Watertemp         = Watertemp;
            model.BackWatertemp     = BackWatertemp;
            model.WorkDate          = WorkDate;
            model.FactDate          = FactDate;
            model.BatteryState      = BatteryState;
            model.Warning           = Warning;
            model.OldFreezeNumber   = OldFreezeNumber;
            model.Megabit           = Megabit;
            model.UseState          = UseState;
            model.ControlValveDate  = ControlValveDate;
            model.SyncFlag          = SyncFlag;
            model.PriceSetNo        = PriceSetNo;
            model.CollectorReadDate = CollectorReadDate;
            model.MeterStatusString = MeterStatusString;
            model.Remnant           = Remnant;

            WebDemo.BLL.WebDemo.ReadNowData bll = new WebDemo.BLL.WebDemo.ReadNowData();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.ReadNowData model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ReadNowData(");
            strSql.Append("MeterID,ReadNumber,ValveState,AttackState,Voltage,ReadDate,InstantNumber,PileNumber,Watertemp,BackWatertemp,WorkDate,FactDate,BatteryState,Warning,OldFreezeNumber,Megabit,UseState,ControlValveDate,SyncFlag,PriceSetNo,CollectorReadDate,MeterStatusString,Remnant)");
            strSql.Append(" values (");
            strSql.Append("@MeterID,@ReadNumber,@ValveState,@AttackState,@Voltage,@ReadDate,@InstantNumber,@PileNumber,@Watertemp,@BackWatertemp,@WorkDate,@FactDate,@BatteryState,@Warning,@OldFreezeNumber,@Megabit,@UseState,@ControlValveDate,@SyncFlag,@PriceSetNo,@CollectorReadDate,@MeterStatusString,@Remnant)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MeterID",           SqlDbType.Int,          4),
                new SqlParameter("@ReadNumber",        SqlDbType.Decimal,      9),
                new SqlParameter("@ValveState",        SqlDbType.Int,          4),
                new SqlParameter("@AttackState",       SqlDbType.Int,          4),
                new SqlParameter("@Voltage",           SqlDbType.Decimal,      9),
                new SqlParameter("@ReadDate",          SqlDbType.DateTime),
                new SqlParameter("@InstantNumber",     SqlDbType.Decimal,      9),
                new SqlParameter("@PileNumber",        SqlDbType.Decimal,      9),
                new SqlParameter("@Watertemp",         SqlDbType.Decimal,      9),
                new SqlParameter("@BackWatertemp",     SqlDbType.Decimal,      9),
                new SqlParameter("@WorkDate",          SqlDbType.Int,          4),
                new SqlParameter("@FactDate",          SqlDbType.VarChar,     50),
                new SqlParameter("@BatteryState",      SqlDbType.Int,          4),
                new SqlParameter("@Warning",           SqlDbType.Int,          4),
                new SqlParameter("@OldFreezeNumber",   SqlDbType.Decimal,      9),
                new SqlParameter("@Megabit",           SqlDbType.Int,          4),
                new SqlParameter("@UseState",          SqlDbType.Int,          4),
                new SqlParameter("@ControlValveDate",  SqlDbType.DateTime),
                new SqlParameter("@SyncFlag",          SqlDbType.Int,          4),
                new SqlParameter("@PriceSetNo",        SqlDbType.Int,          4),
                new SqlParameter("@CollectorReadDate", SqlDbType.DateTime),
                new SqlParameter("@MeterStatusString", SqlDbType.VarChar,   1000),
                new SqlParameter("@Remnant",           SqlDbType.Decimal, 9)
            };
            parameters[0].Value  = model.MeterID;
            parameters[1].Value  = model.ReadNumber;
            parameters[2].Value  = model.ValveState;
            parameters[3].Value  = model.AttackState;
            parameters[4].Value  = model.Voltage;
            parameters[5].Value  = model.ReadDate;
            parameters[6].Value  = model.InstantNumber;
            parameters[7].Value  = model.PileNumber;
            parameters[8].Value  = model.Watertemp;
            parameters[9].Value  = model.BackWatertemp;
            parameters[10].Value = model.WorkDate;
            parameters[11].Value = model.FactDate;
            parameters[12].Value = model.BatteryState;
            parameters[13].Value = model.Warning;
            parameters[14].Value = model.OldFreezeNumber;
            parameters[15].Value = model.Megabit;
            parameters[16].Value = model.UseState;
            parameters[17].Value = model.ControlValveDate;
            parameters[18].Value = model.SyncFlag;
            parameters[19].Value = model.PriceSetNo;
            parameters[20].Value = model.CollectorReadDate;
            parameters[21].Value = model.MeterStatusString;
            parameters[22].Value = model.Remnant;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.ReadNowData DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.ReadNowData model = new WebDemo.Model.WebDemo.ReadNowData();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["MeterID"] != null && row["MeterID"].ToString() != "")
         {
             model.MeterID = int.Parse(row["MeterID"].ToString());
         }
         if (row["ReadNumber"] != null && row["ReadNumber"].ToString() != "")
         {
             model.ReadNumber = decimal.Parse(row["ReadNumber"].ToString());
         }
         if (row["ValveState"] != null && row["ValveState"].ToString() != "")
         {
             model.ValveState = int.Parse(row["ValveState"].ToString());
         }
         if (row["AttackState"] != null && row["AttackState"].ToString() != "")
         {
             model.AttackState = int.Parse(row["AttackState"].ToString());
         }
         if (row["Voltage"] != null && row["Voltage"].ToString() != "")
         {
             model.Voltage = decimal.Parse(row["Voltage"].ToString());
         }
         if (row["ReadDate"] != null && row["ReadDate"].ToString() != "")
         {
             model.ReadDate = DateTime.Parse(row["ReadDate"].ToString());
         }
         if (row["InstantNumber"] != null && row["InstantNumber"].ToString() != "")
         {
             model.InstantNumber = decimal.Parse(row["InstantNumber"].ToString());
         }
         if (row["PileNumber"] != null && row["PileNumber"].ToString() != "")
         {
             model.PileNumber = decimal.Parse(row["PileNumber"].ToString());
         }
         if (row["Watertemp"] != null && row["Watertemp"].ToString() != "")
         {
             model.Watertemp = decimal.Parse(row["Watertemp"].ToString());
         }
         if (row["BackWatertemp"] != null && row["BackWatertemp"].ToString() != "")
         {
             model.BackWatertemp = decimal.Parse(row["BackWatertemp"].ToString());
         }
         if (row["WorkDate"] != null && row["WorkDate"].ToString() != "")
         {
             model.WorkDate = int.Parse(row["WorkDate"].ToString());
         }
         if (row["FactDate"] != null)
         {
             model.FactDate = row["FactDate"].ToString();
         }
         if (row["BatteryState"] != null && row["BatteryState"].ToString() != "")
         {
             model.BatteryState = int.Parse(row["BatteryState"].ToString());
         }
         if (row["Warning"] != null && row["Warning"].ToString() != "")
         {
             model.Warning = int.Parse(row["Warning"].ToString());
         }
         if (row["OldFreezeNumber"] != null && row["OldFreezeNumber"].ToString() != "")
         {
             model.OldFreezeNumber = decimal.Parse(row["OldFreezeNumber"].ToString());
         }
         if (row["Megabit"] != null && row["Megabit"].ToString() != "")
         {
             model.Megabit = int.Parse(row["Megabit"].ToString());
         }
         if (row["UseState"] != null && row["UseState"].ToString() != "")
         {
             model.UseState = int.Parse(row["UseState"].ToString());
         }
         if (row["ControlValveDate"] != null && row["ControlValveDate"].ToString() != "")
         {
             model.ControlValveDate = DateTime.Parse(row["ControlValveDate"].ToString());
         }
         if (row["SyncFlag"] != null && row["SyncFlag"].ToString() != "")
         {
             model.SyncFlag = int.Parse(row["SyncFlag"].ToString());
         }
         if (row["PriceSetNo"] != null && row["PriceSetNo"].ToString() != "")
         {
             model.PriceSetNo = int.Parse(row["PriceSetNo"].ToString());
         }
         if (row["CollectorReadDate"] != null && row["CollectorReadDate"].ToString() != "")
         {
             model.CollectorReadDate = DateTime.Parse(row["CollectorReadDate"].ToString());
         }
         if (row["MeterStatusString"] != null)
         {
             model.MeterStatusString = row["MeterStatusString"].ToString();
         }
         if (row["Remnant"] != null && row["Remnant"].ToString() != "")
         {
             model.Remnant = decimal.Parse(row["Remnant"].ToString());
         }
     }
     return(model);
 }
Esempio n. 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.ReadNowData model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ReadNowData set ");
            strSql.Append("MeterID=@MeterID,");
            strSql.Append("ReadNumber=@ReadNumber,");
            strSql.Append("ValveState=@ValveState,");
            strSql.Append("AttackState=@AttackState,");
            strSql.Append("Voltage=@Voltage,");
            strSql.Append("ReadDate=@ReadDate,");
            strSql.Append("InstantNumber=@InstantNumber,");
            strSql.Append("PileNumber=@PileNumber,");
            strSql.Append("Watertemp=@Watertemp,");
            strSql.Append("BackWatertemp=@BackWatertemp,");
            strSql.Append("WorkDate=@WorkDate,");
            strSql.Append("FactDate=@FactDate,");
            strSql.Append("BatteryState=@BatteryState,");
            strSql.Append("Warning=@Warning,");
            strSql.Append("OldFreezeNumber=@OldFreezeNumber,");
            strSql.Append("Megabit=@Megabit,");
            strSql.Append("UseState=@UseState,");
            strSql.Append("ControlValveDate=@ControlValveDate,");
            strSql.Append("SyncFlag=@SyncFlag,");
            strSql.Append("PriceSetNo=@PriceSetNo,");
            strSql.Append("CollectorReadDate=@CollectorReadDate,");
            strSql.Append("MeterStatusString=@MeterStatusString,");
            strSql.Append("Remnant=@Remnant");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MeterID",           SqlDbType.Int,          4),
                new SqlParameter("@ReadNumber",        SqlDbType.Decimal,      9),
                new SqlParameter("@ValveState",        SqlDbType.Int,          4),
                new SqlParameter("@AttackState",       SqlDbType.Int,          4),
                new SqlParameter("@Voltage",           SqlDbType.Decimal,      9),
                new SqlParameter("@ReadDate",          SqlDbType.DateTime),
                new SqlParameter("@InstantNumber",     SqlDbType.Decimal,      9),
                new SqlParameter("@PileNumber",        SqlDbType.Decimal,      9),
                new SqlParameter("@Watertemp",         SqlDbType.Decimal,      9),
                new SqlParameter("@BackWatertemp",     SqlDbType.Decimal,      9),
                new SqlParameter("@WorkDate",          SqlDbType.Int,          4),
                new SqlParameter("@FactDate",          SqlDbType.VarChar,     50),
                new SqlParameter("@BatteryState",      SqlDbType.Int,          4),
                new SqlParameter("@Warning",           SqlDbType.Int,          4),
                new SqlParameter("@OldFreezeNumber",   SqlDbType.Decimal,      9),
                new SqlParameter("@Megabit",           SqlDbType.Int,          4),
                new SqlParameter("@UseState",          SqlDbType.Int,          4),
                new SqlParameter("@ControlValveDate",  SqlDbType.DateTime),
                new SqlParameter("@SyncFlag",          SqlDbType.Int,          4),
                new SqlParameter("@PriceSetNo",        SqlDbType.Int,          4),
                new SqlParameter("@CollectorReadDate", SqlDbType.DateTime),
                new SqlParameter("@MeterStatusString", SqlDbType.VarChar,   1000),
                new SqlParameter("@Remnant",           SqlDbType.Decimal,      9),
                new SqlParameter("@ID",                SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.MeterID;
            parameters[1].Value  = model.ReadNumber;
            parameters[2].Value  = model.ValveState;
            parameters[3].Value  = model.AttackState;
            parameters[4].Value  = model.Voltage;
            parameters[5].Value  = model.ReadDate;
            parameters[6].Value  = model.InstantNumber;
            parameters[7].Value  = model.PileNumber;
            parameters[8].Value  = model.Watertemp;
            parameters[9].Value  = model.BackWatertemp;
            parameters[10].Value = model.WorkDate;
            parameters[11].Value = model.FactDate;
            parameters[12].Value = model.BatteryState;
            parameters[13].Value = model.Warning;
            parameters[14].Value = model.OldFreezeNumber;
            parameters[15].Value = model.Megabit;
            parameters[16].Value = model.UseState;
            parameters[17].Value = model.ControlValveDate;
            parameters[18].Value = model.SyncFlag;
            parameters[19].Value = model.PriceSetNo;
            parameters[20].Value = model.CollectorReadDate;
            parameters[21].Value = model.MeterStatusString;
            parameters[22].Value = model.Remnant;
            parameters[23].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }