private void ShowInfo(int InstallID) { WebDemo.BLL.WebDemo.InstallFee bll = new WebDemo.BLL.WebDemo.InstallFee(); WebDemo.Model.WebDemo.InstallFee model = bll.GetModel(InstallID); this.lblInstallID.Text = model.InstallID.ToString(); this.lblUserNum.Text = model.UserNum.ToString(); this.lblSingleFee.Text = model.SingleFee.ToString(); this.lblSumFee.Text = model.SumFee.ToString(); this.lblOperDate.Text = model.OperDate.ToString(); this.lblOperatorID.Text = model.OperatorID.ToString(); this.lblSiteID.Text = model.SiteID.ToString(); this.lblMark.Text = model.Mark.ToString(); this.lblInstallMark.Text = model.InstallMark.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.InstallFee model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update InstallFee set "); strSql.Append("UserNum=@UserNum,"); strSql.Append("SingleFee=@SingleFee,"); strSql.Append("SumFee=@SumFee,"); strSql.Append("OperDate=@OperDate,"); strSql.Append("OperatorID=@OperatorID,"); strSql.Append("SiteID=@SiteID,"); strSql.Append("Mark=@Mark,"); strSql.Append("InstallMark=@InstallMark"); strSql.Append(" where InstallID=@InstallID"); SqlParameter[] parameters = { new SqlParameter("@UserNum", SqlDbType.Int, 4), new SqlParameter("@SingleFee", SqlDbType.Decimal, 9), new SqlParameter("@SumFee", SqlDbType.Decimal, 9), new SqlParameter("@OperDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4), new SqlParameter("@Mark", SqlDbType.Int, 4), new SqlParameter("@InstallMark", SqlDbType.Int, 4), new SqlParameter("@InstallID", SqlDbType.Int, 4) }; parameters[0].Value = model.UserNum; parameters[1].Value = model.SingleFee; parameters[2].Value = model.SumFee; parameters[3].Value = model.OperDate; parameters[4].Value = model.OperatorID; parameters[5].Value = model.SiteID; parameters[6].Value = model.Mark; parameters[7].Value = model.InstallMark; parameters[8].Value = model.InstallID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.InstallFee DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.InstallFee model = new WebDemo.Model.WebDemo.InstallFee(); if (row != null) { if (row["InstallID"] != null && row["InstallID"].ToString() != "") { model.InstallID = int.Parse(row["InstallID"].ToString()); } if (row["UserNum"] != null && row["UserNum"].ToString() != "") { model.UserNum = int.Parse(row["UserNum"].ToString()); } if (row["SingleFee"] != null && row["SingleFee"].ToString() != "") { model.SingleFee = decimal.Parse(row["SingleFee"].ToString()); } if (row["SumFee"] != null && row["SumFee"].ToString() != "") { model.SumFee = decimal.Parse(row["SumFee"].ToString()); } if (row["OperDate"] != null && row["OperDate"].ToString() != "") { model.OperDate = DateTime.Parse(row["OperDate"].ToString()); } if (row["OperatorID"] != null && row["OperatorID"].ToString() != "") { model.OperatorID = int.Parse(row["OperatorID"].ToString()); } if (row["SiteID"] != null && row["SiteID"].ToString() != "") { model.SiteID = int.Parse(row["SiteID"].ToString()); } if (row["Mark"] != null && row["Mark"].ToString() != "") { model.Mark = int.Parse(row["Mark"].ToString()); } if (row["InstallMark"] != null && row["InstallMark"].ToString() != "") { model.InstallMark = int.Parse(row["InstallMark"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WebDemo.Model.WebDemo.InstallFee model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into InstallFee("); strSql.Append("UserNum,SingleFee,SumFee,OperDate,OperatorID,SiteID,Mark,InstallMark)"); strSql.Append(" values ("); strSql.Append("@UserNum,@SingleFee,@SumFee,@OperDate,@OperatorID,@SiteID,@Mark,@InstallMark)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserNum", SqlDbType.Int, 4), new SqlParameter("@SingleFee", SqlDbType.Decimal, 9), new SqlParameter("@SumFee", SqlDbType.Decimal, 9), new SqlParameter("@OperDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4), new SqlParameter("@Mark", SqlDbType.Int, 4), new SqlParameter("@InstallMark", SqlDbType.Int, 4) }; parameters[0].Value = model.UserNum; parameters[1].Value = model.SingleFee; parameters[2].Value = model.SumFee; parameters[3].Value = model.OperDate; parameters[4].Value = model.OperatorID; parameters[5].Value = model.SiteID; parameters[6].Value = model.Mark; parameters[7].Value = model.InstallMark; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.InstallFee GetModel(int InstallID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 InstallID,UserNum,SingleFee,SumFee,OperDate,OperatorID,SiteID,Mark,InstallMark from InstallFee "); strSql.Append(" where InstallID=@InstallID"); SqlParameter[] parameters = { new SqlParameter("@InstallID", SqlDbType.Int, 4) }; parameters[0].Value = InstallID; WebDemo.Model.WebDemo.InstallFee model = new WebDemo.Model.WebDemo.InstallFee(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtUserNum.Text)) { strErr += "UserNum格式错误!\\n"; } if (!PageValidate.IsDecimal(txtSingleFee.Text)) { strErr += "SingleFee格式错误!\\n"; } if (!PageValidate.IsDecimal(txtSumFee.Text)) { strErr += "SumFee格式错误!\\n"; } if (!PageValidate.IsDateTime(txtOperDate.Text)) { strErr += "OperDate格式错误!\\n"; } if (!PageValidate.IsNumber(txtOperatorID.Text)) { strErr += "OperatorID格式错误!\\n"; } if (!PageValidate.IsNumber(txtSiteID.Text)) { strErr += "SiteID格式错误!\\n"; } if (!PageValidate.IsNumber(txtMark.Text)) { strErr += "Mark格式错误!\\n"; } if (!PageValidate.IsNumber(txtInstallMark.Text)) { strErr += "InstallMark格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int UserNum = int.Parse(this.txtUserNum.Text); decimal SingleFee = decimal.Parse(this.txtSingleFee.Text); decimal SumFee = decimal.Parse(this.txtSumFee.Text); DateTime OperDate = DateTime.Parse(this.txtOperDate.Text); int OperatorID = int.Parse(this.txtOperatorID.Text); int SiteID = int.Parse(this.txtSiteID.Text); int Mark = int.Parse(this.txtMark.Text); int InstallMark = int.Parse(this.txtInstallMark.Text); WebDemo.Model.WebDemo.InstallFee model = new WebDemo.Model.WebDemo.InstallFee(); model.UserNum = UserNum; model.SingleFee = SingleFee; model.SumFee = SumFee; model.OperDate = OperDate; model.OperatorID = OperatorID; model.SiteID = SiteID; model.Mark = Mark; model.InstallMark = InstallMark; WebDemo.BLL.WebDemo.InstallFee bll = new WebDemo.BLL.WebDemo.InstallFee(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }