/// <summary> /// 更新一条数据 /// </summary> public bool Update(YueYePlat.Model.logistouser model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update logistouser set "); strSql.Append("LogisCompanyID=@LogisCompanyID,"); strSql.Append("UserID=@UserID,"); strSql.Append("CurDate=@CurDate,"); strSql.Append("OrderCount=@OrderCount"); strSql.Append(" where ID=@ID"); MySqlParameter[] parameters = { new MySqlParameter("@LogisCompanyID", MySqlDbType.VarChar, 50), new MySqlParameter("@UserID", MySqlDbType.VarChar, 50), new MySqlParameter("@CurDate", MySqlDbType.DateTime), new MySqlParameter("@OrderCount", MySqlDbType.Int32, 11), new MySqlParameter("@ID", MySqlDbType.Int32, 11) }; parameters[0].Value = model.LogisCompanyID; parameters[1].Value = model.UserID; parameters[2].Value = model.CurDate; parameters[3].Value = model.OrderCount; parameters[4].Value = model.ID; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public YueYePlat.Model.logistouser DataRowToModel(DataRow row) { YueYePlat.Model.logistouser model = new YueYePlat.Model.logistouser(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["LogisCompanyID"] != null) { model.LogisCompanyID = row["LogisCompanyID"].ToString(); } if (row["UserID"] != null) { model.UserID = row["UserID"].ToString(); } if (row["CurDate"] != null && row["CurDate"].ToString() != "") { model.CurDate = DateTime.Parse(row["CurDate"].ToString()); } if (row["OrderCount"] != null && row["OrderCount"].ToString() != "") { model.OrderCount = int.Parse(row["OrderCount"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(YueYePlat.Model.logistouser model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into logistouser("); strSql.Append("LogisCompanyID,UserID,CurDate,OrderCount)"); strSql.Append(" values ("); strSql.Append("@LogisCompanyID,@UserID,@CurDate,@OrderCount)"); MySqlParameter[] parameters = { new MySqlParameter("@LogisCompanyID", MySqlDbType.VarChar, 50), new MySqlParameter("@UserID", MySqlDbType.VarChar, 50), new MySqlParameter("@CurDate", MySqlDbType.DateTime), new MySqlParameter("@OrderCount", MySqlDbType.Int32, 11) }; parameters[0].Value = model.LogisCompanyID; parameters[1].Value = model.UserID; parameters[2].Value = model.CurDate; parameters[3].Value = model.OrderCount; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public YueYePlat.Model.logistouser GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,LogisCompanyID,UserID,CurDate,OrderCount from logistouser "); strSql.Append(" where ID=@ID"); MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.Int32) }; parameters[0].Value = ID; YueYePlat.Model.logistouser model = new YueYePlat.Model.logistouser(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }