protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtUsersID.Text)) { strErr += "UsersID格式错误!\\n"; } if (!PageValidate.IsNumber(txtFareID.Text)) { strErr += "FareID格式错误!\\n"; } if (!PageValidate.IsDecimal(txtFee.Text)) { strErr += "Fee格式错误!\\n"; } if (!PageValidate.IsDecimal(txtFactFee.Text)) { strErr += "FactFee格式错误!\\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 (strErr != "") { MessageBox.Show(this, strErr); return; } int UsersID = int.Parse(this.txtUsersID.Text); int FareID = int.Parse(this.txtFareID.Text); decimal Fee = decimal.Parse(this.txtFee.Text); decimal FactFee = decimal.Parse(this.txtFactFee.Text); DateTime OperDate = DateTime.Parse(this.txtOperDate.Text); int OperatorID = int.Parse(this.txtOperatorID.Text); int SiteID = int.Parse(this.txtSiteID.Text); WebDemo.Model.WebDemo.FeeOperation model = new WebDemo.Model.WebDemo.FeeOperation(); model.UsersID = UsersID; model.FareID = FareID; model.Fee = Fee; model.FactFee = FactFee; model.OperDate = OperDate; model.OperatorID = OperatorID; model.SiteID = SiteID; WebDemo.BLL.WebDemo.FeeOperation bll = new WebDemo.BLL.WebDemo.FeeOperation(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
private void ShowInfo(int FID) { WebDemo.BLL.WebDemo.FeeOperation bll = new WebDemo.BLL.WebDemo.FeeOperation(); WebDemo.Model.WebDemo.FeeOperation model = bll.GetModel(FID); this.lblFID.Text = model.FID.ToString(); this.txtUsersID.Text = model.UsersID.ToString(); this.txtFareID.Text = model.FareID.ToString(); this.txtFee.Text = model.Fee.ToString(); this.txtFactFee.Text = model.FactFee.ToString(); this.txtOperDate.Text = model.OperDate.ToString(); this.txtOperatorID.Text = model.OperatorID.ToString(); this.txtSiteID.Text = model.SiteID.ToString(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WebDemo.Model.WebDemo.FeeOperation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update FeeOperation set "); strSql.Append("UsersID=@UsersID,"); strSql.Append("FareID=@FareID,"); strSql.Append("Fee=@Fee,"); strSql.Append("FactFee=@FactFee,"); strSql.Append("OperDate=@OperDate,"); strSql.Append("OperatorID=@OperatorID,"); strSql.Append("SiteID=@SiteID"); strSql.Append(" where FID=@FID"); SqlParameter[] parameters = { new SqlParameter("@UsersID", SqlDbType.Int, 4), new SqlParameter("@FareID", SqlDbType.Int, 4), new SqlParameter("@Fee", SqlDbType.Decimal, 9), new SqlParameter("@FactFee", SqlDbType.Decimal, 9), new SqlParameter("@OperDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4), new SqlParameter("@FID", SqlDbType.Int, 4) }; parameters[0].Value = model.UsersID; parameters[1].Value = model.FareID; parameters[2].Value = model.Fee; parameters[3].Value = model.FactFee; parameters[4].Value = model.OperDate; parameters[5].Value = model.OperatorID; parameters[6].Value = model.SiteID; parameters[7].Value = model.FID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.FeeOperation DataRowToModel(DataRow row) { WebDemo.Model.WebDemo.FeeOperation model = new WebDemo.Model.WebDemo.FeeOperation(); if (row != null) { if (row["FID"] != null && row["FID"].ToString() != "") { model.FID = int.Parse(row["FID"].ToString()); } if (row["UsersID"] != null && row["UsersID"].ToString() != "") { model.UsersID = int.Parse(row["UsersID"].ToString()); } if (row["FareID"] != null && row["FareID"].ToString() != "") { model.FareID = int.Parse(row["FareID"].ToString()); } if (row["Fee"] != null && row["Fee"].ToString() != "") { model.Fee = decimal.Parse(row["Fee"].ToString()); } if (row["FactFee"] != null && row["FactFee"].ToString() != "") { model.FactFee = decimal.Parse(row["FactFee"].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()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WebDemo.Model.WebDemo.FeeOperation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into FeeOperation("); strSql.Append("UsersID,FareID,Fee,FactFee,OperDate,OperatorID,SiteID)"); strSql.Append(" values ("); strSql.Append("@UsersID,@FareID,@Fee,@FactFee,@OperDate,@OperatorID,@SiteID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UsersID", SqlDbType.Int, 4), new SqlParameter("@FareID", SqlDbType.Int, 4), new SqlParameter("@Fee", SqlDbType.Decimal, 9), new SqlParameter("@FactFee", SqlDbType.Decimal, 9), new SqlParameter("@OperDate", SqlDbType.DateTime), new SqlParameter("@OperatorID", SqlDbType.Int, 4), new SqlParameter("@SiteID", SqlDbType.Int, 4) }; parameters[0].Value = model.UsersID; parameters[1].Value = model.FareID; parameters[2].Value = model.Fee; parameters[3].Value = model.FactFee; parameters[4].Value = model.OperDate; parameters[5].Value = model.OperatorID; parameters[6].Value = model.SiteID; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WebDemo.Model.WebDemo.FeeOperation GetModel(int FID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 FID,UsersID,FareID,Fee,FactFee,OperDate,OperatorID,SiteID from FeeOperation "); strSql.Append(" where FID=@FID"); SqlParameter[] parameters = { new SqlParameter("@FID", SqlDbType.Int, 4) }; parameters[0].Value = FID; WebDemo.Model.WebDemo.FeeOperation model = new WebDemo.Model.WebDemo.FeeOperation(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }