/// <summary> /// 更新一条数据 /// </summary> public void Update(Hownet.Model.SalesPrice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SalesPrice set "); strSql.Append("MTID=@MTID,"); strSql.Append("Price=@Price,"); strSql.Append("SalesID=@SalesID,"); strSql.Append("Amount=@Amount,"); strSql.Append("Money=@Money,"); strSql.Append("Remark=@Remark"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@MTID", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@SalesID", SqlDbType.Int, 4), new SqlParameter("@Amount", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.NVarChar, 4000) }; parameters[0].Value = model.ID; parameters[1].Value = model.MTID; parameters[2].Value = model.Price; parameters[3].Value = model.SalesID; parameters[4].Value = model.Amount; parameters[5].Value = model.Money; parameters[6].Value = model.Remark; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public Hownet.Model.SalesPrice GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,MTID,Price,SalesID,Amount,Money,Remark from SalesPrice "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Hownet.Model.SalesPrice model = new Hownet.Model.SalesPrice(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["MTID"].ToString() != "") { model.MTID = int.Parse(ds.Tables[0].Rows[0]["MTID"].ToString()); } if (ds.Tables[0].Rows[0]["Price"].ToString() != "") { model.Price = decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString()); } if (ds.Tables[0].Rows[0]["SalesID"].ToString() != "") { model.SalesID = int.Parse(ds.Tables[0].Rows[0]["SalesID"].ToString()); } if (ds.Tables[0].Rows[0]["Amount"].ToString() != "") { model.Amount = int.Parse(ds.Tables[0].Rows[0]["Amount"].ToString()); } if (ds.Tables[0].Rows[0]["Money"].ToString() != "") { model.Money = decimal.Parse(ds.Tables[0].Rows[0]["Money"].ToString()); } model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); model.A = 1; return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hownet.Model.SalesPrice model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SalesPrice("); strSql.Append("MTID,Price,SalesID,Amount,Money,Remark)"); strSql.Append(" values ("); strSql.Append("@MTID,@Price,@SalesID,@Amount,@Money,@Remark)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MTID", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@SalesID", SqlDbType.Int, 4), new SqlParameter("@Amount", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.NVarChar, 4000) }; parameters[0].Value = model.MTID; parameters[1].Value = model.Price; parameters[2].Value = model.SalesID; parameters[3].Value = model.Amount; parameters[4].Value = model.Money; parameters[5].Value = model.Remark; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }