private void ShowInfo(int ID) { WebDemo.BLL.WebDemo.FreezeDay bll = new WebDemo.BLL.WebDemo.FreezeDay(); WebDemo.Model.WebDemo.FreezeDay model = bll.GetModel(ID); this.lblID.Text = model.ID.ToString(); this.lblMeterID.Text = model.MeterID.ToString(); this.lblFreezeDate.Text = model.FreezeDate; this.txtFreezeNumber.Text = model.FreezeNumber.ToString(); this.lblReadDate.Text = model.ReadDate.ToString(); this.txtInstantNumber.Text = model.InstantNumber.ToString(); this.txtPileNumber.Text = model.PileNumber.ToString(); this.txtWatertemp.Text = model.Watertemp.ToString(); this.txtBackWatertemp.Text = model.BackWatertemp.ToString(); this.txtWorkDate.Text = model.WorkDate.ToString(); this.txtFactDate.Text = model.FactDate; this.txtBatteryState.Text = model.BatteryState.ToString(); this.txtWarning.Text = model.Warning.ToString(); this.txtValveState.Text = model.ValveState.ToString(); this.txtUploadFlag.Text = model.UploadFlag.ToString(); this.txtOldFreezeNumber.Text = model.OldFreezeNumber.ToString(); this.txtMegabit.Text = model.Megabit.ToString(); this.txtPriceSetNo.Text = model.PriceSetNo.ToString(); this.txtCollectorReadDate.Text = model.CollectorReadDate.ToString(); this.txtMeterStatusString.Text = model.MeterStatusString; this.txtSyncFlag.Text = model.SyncFlag.ToString(); this.txtVerifyValue.Text = model.VerifyValue.ToString(); this.txtRemnant.Text = model.Remnant.ToString(); this.txtReadMode.Text = model.ReadMode.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.FreezeDay GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,MeterID,FreezeDate,FreezeNumber,ReadDate,InstantNumber,PileNumber,Watertemp,BackWatertemp,WorkDate,FactDate,BatteryState,Warning,ValveState,UploadFlag,OldFreezeNumber,Megabit,PriceSetNo,CollectorReadDate,MeterStatusString,SyncFlag,VerifyValue,Remnant,ReadMode from FreezeDay "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; WebDemo.Model.WebDemo.FreezeDay model = new WebDemo.Model.WebDemo.FreezeDay(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsDecimal(txtFreezeNumber.Text)) { strErr += "日冻结读数格式错误!\\n"; } if (!PageValidate.IsDateTime(txtReadDate.Text)) { strErr += "抄表时间格式错误!\\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.IsNumber(txtValveState.Text)) { strErr += "ValveState格式错误!\\n"; } if (!PageValidate.IsNumber(txtUploadFlag.Text)) { strErr += "UploadFlag格式错误!\\n"; } if (!PageValidate.IsDecimal(txtOldFreezeNumber.Text)) { strErr += "OldFreezeNumber格式错误!\\n"; } if (!PageValidate.IsNumber(txtMegabit.Text)) { strErr += "Megabit格式错误!\\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.IsNumber(txtSyncFlag.Text)) { strErr += "SyncFlag格式错误!\\n"; } if (!PageValidate.IsNumber(txtVerifyValue.Text)) { strErr += "VerifyValue格式错误!\\n"; } if (!PageValidate.IsDecimal(txtRemnant.Text)) { strErr += "Remnant格式错误!\\n"; } if (!PageValidate.IsNumber(txtReadMode.Text)) { strErr += "ReadMode格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int ID = int.Parse(this.lblID.Text); int MeterID = int.Parse(this.lblMeterID.Text); string FreezeDate = this.lblFreezeDate.Text; decimal FreezeNumber = decimal.Parse(this.txtFreezeNumber.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); int ValveState = int.Parse(this.txtValveState.Text); int UploadFlag = int.Parse(this.txtUploadFlag.Text); decimal OldFreezeNumber = decimal.Parse(this.txtOldFreezeNumber.Text); int Megabit = int.Parse(this.txtMegabit.Text); int PriceSetNo = int.Parse(this.txtPriceSetNo.Text); DateTime CollectorReadDate = DateTime.Parse(this.txtCollectorReadDate.Text); string MeterStatusString = this.txtMeterStatusString.Text; int SyncFlag = int.Parse(this.txtSyncFlag.Text); int VerifyValue = int.Parse(this.txtVerifyValue.Text); decimal Remnant = decimal.Parse(this.txtRemnant.Text); int ReadMode = int.Parse(this.txtReadMode.Text); WebDemo.Model.WebDemo.FreezeDay model = new WebDemo.Model.WebDemo.FreezeDay(); model.ID = ID; model.MeterID = MeterID; model.FreezeDate = FreezeDate; model.FreezeNumber = FreezeNumber; 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.ValveState = ValveState; model.UploadFlag = UploadFlag; model.OldFreezeNumber = OldFreezeNumber; model.Megabit = Megabit; model.PriceSetNo = PriceSetNo; model.CollectorReadDate = CollectorReadDate; model.MeterStatusString = MeterStatusString; model.SyncFlag = SyncFlag; model.VerifyValue = VerifyValue; model.Remnant = Remnant; model.ReadMode = ReadMode; WebDemo.BLL.WebDemo.FreezeDay bll = new WebDemo.BLL.WebDemo.FreezeDay(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WebDemo.Model.WebDemo.FreezeDay model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into FreezeDay("); strSql.Append("MeterID,FreezeDate,FreezeNumber,ReadDate,InstantNumber,PileNumber,Watertemp,BackWatertemp,WorkDate,FactDate,BatteryState,Warning,ValveState,UploadFlag,OldFreezeNumber,Megabit,PriceSetNo,CollectorReadDate,MeterStatusString,SyncFlag,VerifyValue,Remnant,ReadMode)"); strSql.Append(" values ("); strSql.Append("@MeterID,@FreezeDate,@FreezeNumber,@ReadDate,@InstantNumber,@PileNumber,@Watertemp,@BackWatertemp,@WorkDate,@FactDate,@BatteryState,@Warning,@ValveState,@UploadFlag,@OldFreezeNumber,@Megabit,@PriceSetNo,@CollectorReadDate,@MeterStatusString,@SyncFlag,@VerifyValue,@Remnant,@ReadMode)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MeterID", SqlDbType.Int, 4), new SqlParameter("@FreezeDate", SqlDbType.VarChar, 10), new SqlParameter("@FreezeNumber", 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("@ValveState", SqlDbType.Int, 4), new SqlParameter("@UploadFlag", SqlDbType.Int, 4), new SqlParameter("@OldFreezeNumber", SqlDbType.Decimal, 9), new SqlParameter("@Megabit", SqlDbType.Int, 4), new SqlParameter("@PriceSetNo", SqlDbType.Int, 4), new SqlParameter("@CollectorReadDate", SqlDbType.DateTime), new SqlParameter("@MeterStatusString", SqlDbType.VarChar, 1000), new SqlParameter("@SyncFlag", SqlDbType.Int, 4), new SqlParameter("@VerifyValue", SqlDbType.Int, 4), new SqlParameter("@Remnant", SqlDbType.Decimal, 9), new SqlParameter("@ReadMode", SqlDbType.Int, 4) }; parameters[0].Value = model.MeterID; parameters[1].Value = model.FreezeDate; parameters[2].Value = model.FreezeNumber; parameters[3].Value = model.ReadDate; parameters[4].Value = model.InstantNumber; parameters[5].Value = model.PileNumber; parameters[6].Value = model.Watertemp; parameters[7].Value = model.BackWatertemp; parameters[8].Value = model.WorkDate; parameters[9].Value = model.FactDate; parameters[10].Value = model.BatteryState; parameters[11].Value = model.Warning; parameters[12].Value = model.ValveState; parameters[13].Value = model.UploadFlag; parameters[14].Value = model.OldFreezeNumber; parameters[15].Value = model.Megabit; parameters[16].Value = model.PriceSetNo; parameters[17].Value = model.CollectorReadDate; parameters[18].Value = model.MeterStatusString; parameters[19].Value = model.SyncFlag; parameters[20].Value = model.VerifyValue; parameters[21].Value = model.Remnant; parameters[22].Value = model.ReadMode; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.FreezeDay DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.FreezeDay model = new WebDemo.Model.WebDemo.FreezeDay(); 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["FreezeDate"] != null) { model.FreezeDate = row["FreezeDate"].ToString(); } if (row["FreezeNumber"] != null && row["FreezeNumber"].ToString() != "") { model.FreezeNumber = decimal.Parse(row["FreezeNumber"].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["ValveState"] != null && row["ValveState"].ToString() != "") { model.ValveState = int.Parse(row["ValveState"].ToString()); } if (row["UploadFlag"] != null && row["UploadFlag"].ToString() != "") { model.UploadFlag = int.Parse(row["UploadFlag"].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["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["SyncFlag"] != null && row["SyncFlag"].ToString() != "") { model.SyncFlag = int.Parse(row["SyncFlag"].ToString()); } if (row["VerifyValue"] != null && row["VerifyValue"].ToString() != "") { model.VerifyValue = int.Parse(row["VerifyValue"].ToString()); } if (row["Remnant"] != null && row["Remnant"].ToString() != "") { model.Remnant = decimal.Parse(row["Remnant"].ToString()); } if (row["ReadMode"] != null && row["ReadMode"].ToString() != "") { model.ReadMode = int.Parse(row["ReadMode"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.FreezeDay model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update FreezeDay set "); strSql.Append("FreezeNumber=@FreezeNumber,"); 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("ValveState=@ValveState,"); strSql.Append("UploadFlag=@UploadFlag,"); strSql.Append("OldFreezeNumber=@OldFreezeNumber,"); strSql.Append("Megabit=@Megabit,"); strSql.Append("PriceSetNo=@PriceSetNo,"); strSql.Append("CollectorReadDate=@CollectorReadDate,"); strSql.Append("MeterStatusString=@MeterStatusString,"); strSql.Append("SyncFlag=@SyncFlag,"); strSql.Append("VerifyValue=@VerifyValue,"); strSql.Append("Remnant=@Remnant,"); strSql.Append("ReadMode=@ReadMode"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@FreezeNumber", SqlDbType.Decimal, 9), 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("@ValveState", SqlDbType.Int, 4), new SqlParameter("@UploadFlag", SqlDbType.Int, 4), new SqlParameter("@OldFreezeNumber", SqlDbType.Decimal, 9), new SqlParameter("@Megabit", SqlDbType.Int, 4), new SqlParameter("@PriceSetNo", SqlDbType.Int, 4), new SqlParameter("@CollectorReadDate", SqlDbType.DateTime), new SqlParameter("@MeterStatusString", SqlDbType.VarChar, 1000), new SqlParameter("@SyncFlag", SqlDbType.Int, 4), new SqlParameter("@VerifyValue", SqlDbType.Int, 4), new SqlParameter("@Remnant", SqlDbType.Decimal, 9), new SqlParameter("@ReadMode", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@MeterID", SqlDbType.Int, 4), new SqlParameter("@FreezeDate", SqlDbType.VarChar, 10), new SqlParameter("@ReadDate", SqlDbType.DateTime) }; parameters[0].Value = model.FreezeNumber; parameters[1].Value = model.InstantNumber; parameters[2].Value = model.PileNumber; parameters[3].Value = model.Watertemp; parameters[4].Value = model.BackWatertemp; parameters[5].Value = model.WorkDate; parameters[6].Value = model.FactDate; parameters[7].Value = model.BatteryState; parameters[8].Value = model.Warning; parameters[9].Value = model.ValveState; parameters[10].Value = model.UploadFlag; parameters[11].Value = model.OldFreezeNumber; parameters[12].Value = model.Megabit; parameters[13].Value = model.PriceSetNo; parameters[14].Value = model.CollectorReadDate; parameters[15].Value = model.MeterStatusString; parameters[16].Value = model.SyncFlag; parameters[17].Value = model.VerifyValue; parameters[18].Value = model.Remnant; parameters[19].Value = model.ReadMode; parameters[20].Value = model.ID; parameters[21].Value = model.MeterID; parameters[22].Value = model.FreezeDate; parameters[23].Value = model.ReadDate; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }