/// <summary> /// 更新一条数据 /// </summary> public void Update(Model.OnLinePayStatus model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update OnLinePayStatus set "); strSql.Append("orderNo=@orderNo,"); strSql.Append("onLinePayType=@onLinePayType,"); strSql.Append("payStatus=@payStatus,"); strSql.Append("status=@status,"); strSql.Append("count=@count,"); strSql.Append("remark=@remark,"); strSql.Append("addTime=@addTime"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@orderNo", SqlDbType.VarChar, 50), new SqlParameter("@onLinePayType", SqlDbType.Int, 4), new SqlParameter("@payStatus", SqlDbType.Int, 4), new SqlParameter("@status", SqlDbType.Int, 4), new SqlParameter("@count", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 150), new SqlParameter("@addTime", SqlDbType.DateTime) }; parameters[0].Value = model.id; parameters[1].Value = model.orderNo; parameters[2].Value = model.onLinePayType; parameters[3].Value = model.payStatus; parameters[4].Value = model.status; parameters[5].Value = model.count; parameters[6].Value = model.remark; parameters[7].Value = model.addTime; DBHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.OnLinePayStatus GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,orderNo,onLinePayType,payStatus,status,count,remark,addTime from OnLinePayStatus "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.OnLinePayStatus model = new Model.OnLinePayStatus(); 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()); } model.orderNo = ds.Tables[0].Rows[0]["orderNo"].ToString(); if (ds.Tables[0].Rows[0]["onLinePayType"].ToString() != "") { model.onLinePayType = int.Parse(ds.Tables[0].Rows[0]["onLinePayType"].ToString()); } if (ds.Tables[0].Rows[0]["payStatus"].ToString() != "") { model.payStatus = int.Parse(ds.Tables[0].Rows[0]["payStatus"].ToString()); } if (ds.Tables[0].Rows[0]["status"].ToString() != "") { model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } if (ds.Tables[0].Rows[0]["count"].ToString() != "") { model.count = int.Parse(ds.Tables[0].Rows[0]["count"].ToString()); } model.remark = ds.Tables[0].Rows[0]["remark"].ToString(); if (ds.Tables[0].Rows[0]["addTime"].ToString() != "") { model.addTime = DateTime.Parse(ds.Tables[0].Rows[0]["addTime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Model.OnLinePayStatus model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OnLinePayStatus("); strSql.Append("orderNo,onLinePayType,payStatus,status,count,remark,addTime)"); strSql.Append(" values ("); strSql.Append("@orderNo,@onLinePayType,@payStatus,@status,@count,@remark,@addTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@orderNo", SqlDbType.VarChar, 50), new SqlParameter("@onLinePayType", SqlDbType.Int, 4), new SqlParameter("@payStatus", SqlDbType.Int, 4), new SqlParameter("@status", SqlDbType.Int, 4), new SqlParameter("@count", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 150), new SqlParameter("@addTime", SqlDbType.DateTime) }; parameters[0].Value = model.orderNo; parameters[1].Value = model.onLinePayType; parameters[2].Value = model.payStatus; parameters[3].Value = model.status; parameters[4].Value = model.count; parameters[5].Value = model.remark; parameters[6].Value = model.addTime; object obj = DBHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }