/// <summary> /// 更新一条数据 /// </summary> public bool Update(WalleProject.Model.t_pricerecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_pricerecord set "); strSql.Append("pri_date=@pri_date,"); strSql.Append("pri_price=@pri_price,"); strSql.Append("pri_com_ID=@pri_com_ID"); strSql.Append(" where pri_ID=@pri_ID"); MySqlParameter[] parameters = { new MySqlParameter("@pri_date", MySqlDbType.Date), new MySqlParameter("@pri_price", MySqlDbType.Decimal, 10), new MySqlParameter("@pri_com_ID", MySqlDbType.Int32, 10), new MySqlParameter("@pri_ID", MySqlDbType.Int32, 10) }; parameters[0].Value = model.pri_date; parameters[1].Value = model.pri_price; parameters[2].Value = model.pri_com_ID; parameters[3].Value = model.pri_ID; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsDateTime(txtpri_date.Text)) { strErr += "pri_date格式错误!\\n"; } if (!PageValidate.IsDecimal(txtpri_price.Text)) { strErr += "pri_price格式错误!\\n"; } if (!PageValidate.IsNumber(txtpri_com_ID.Text)) { strErr += "pri_com_ID格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } DateTime pri_date = DateTime.Parse(this.txtpri_date.Text); decimal pri_price = decimal.Parse(this.txtpri_price.Text); int pri_com_ID = int.Parse(this.txtpri_com_ID.Text); WalleProject.Model.t_pricerecord model = new WalleProject.Model.t_pricerecord(); model.pri_date = pri_date; model.pri_price = pri_price; model.pri_com_ID = pri_com_ID; WalleProject.BLL.t_pricerecord bll = new WalleProject.BLL.t_pricerecord(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
private void ShowInfo(int pri_ID) { WalleProject.BLL.t_pricerecord bll = new WalleProject.BLL.t_pricerecord(); WalleProject.Model.t_pricerecord model = bll.GetModel(pri_ID); this.txtpri_date.Text = model.pri_date.ToString(); this.txtpri_price.Text = model.pri_price.ToString(); this.txtpri_com_ID.Text = model.pri_com_ID.ToString(); this.lblpri_ID.Text = model.pri_ID.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public WalleProject.Model.t_pricerecord DataRowToModel(DataRow row) { WalleProject.Model.t_pricerecord model = new WalleProject.Model.t_pricerecord(); if (row != null) { if (row["pri_date"] != null && row["pri_date"].ToString() != "") { model.pri_date = DateTime.Parse(row["pri_date"].ToString()); } if (row["pri_price"] != null && row["pri_price"].ToString() != "") { model.pri_price = decimal.Parse(row["pri_price"].ToString()); } if (row["pri_com_ID"] != null && row["pri_com_ID"].ToString() != "") { model.pri_com_ID = int.Parse(row["pri_com_ID"].ToString()); } if (row["pri_ID"] != null && row["pri_ID"].ToString() != "") { model.pri_ID = int.Parse(row["pri_ID"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public WalleProject.Model.t_pricerecord GetModel(int pri_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select pri_date,pri_price,pri_com_ID,pri_ID from t_pricerecord "); strSql.Append(" where pri_ID=@pri_ID"); MySqlParameter[] parameters = { new MySqlParameter("@pri_ID", MySqlDbType.Int32) }; parameters[0].Value = pri_ID; WalleProject.Model.t_pricerecord model = new WalleProject.Model.t_pricerecord(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }