/// <summary> /// 增加一条数据 /// </summary> public bool Add(YueYePlat.Model.vehicledoors model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into vehicledoors("); strSql.Append("DeliveryId,Longitude,Latitude,OpenClose,DoorTime,DoorPhoto)"); strSql.Append(" values ("); strSql.Append("@DeliveryId,@Longitude,@Latitude,@OpenClose,@DoorTime,@DoorPhoto)"); MySqlParameter[] parameters = { new MySqlParameter("@DeliveryId", MySqlDbType.VarChar, 16), new MySqlParameter("@Longitude", MySqlDbType.Double), new MySqlParameter("@Latitude", MySqlDbType.Double), new MySqlParameter("@OpenClose", MySqlDbType.Bit), new MySqlParameter("@DoorTime", MySqlDbType.DateTime), new MySqlParameter("@DoorPhoto", MySqlDbType.VarChar, 100) }; parameters[0].Value = model.DeliveryId; parameters[1].Value = model.Longitude; parameters[2].Value = model.Latitude; parameters[3].Value = model.OpenClose; parameters[4].Value = model.DoorTime; parameters[5].Value = model.DoorPhoto; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public YueYePlat.Model.vehicledoors DataRowToModel(DataRow row) { YueYePlat.Model.vehicledoors model = new YueYePlat.Model.vehicledoors(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["DeliveryId"] != null) { model.DeliveryId = row["DeliveryId"].ToString(); } if (row["Longitude"] != null && row["Longitude"].ToString() != "") { model.Longitude = Double.Parse(row["Longitude"].ToString()); } if (row["Latitude"] != null && row["Latitude"].ToString() != "") { model.Latitude = Double.Parse(row["Latitude"].ToString()); } if (row["OpenClose"] != null && row["OpenClose"].ToString() != "") { if ((row["OpenClose"].ToString() == "1") || (row["OpenClose"].ToString().ToLower() == "true")) { model.OpenClose = true; } else { model.OpenClose = false; } } if (row["DoorTime"] != null && row["DoorTime"].ToString() != "") { model.DoorTime = DateTime.Parse(row["DoorTime"].ToString()); } if (row["DoorPhoto"] != null) { model.DoorPhoto = row["DoorPhoto"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(YueYePlat.Model.vehicledoors model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update vehicledoors set "); strSql.Append("DeliveryId=@DeliveryId,"); strSql.Append("Longitude=@Longitude,"); strSql.Append("Latitude=@Latitude,"); strSql.Append("OpenClose=@OpenClose,"); strSql.Append("DoorTime=@DoorTime,"); strSql.Append("DoorPhoto=@DoorPhoto"); strSql.Append(" where Id=@Id"); MySqlParameter[] parameters = { new MySqlParameter("@DeliveryId", MySqlDbType.VarChar, 16), new MySqlParameter("@Longitude", MySqlDbType.Double), new MySqlParameter("@Latitude", MySqlDbType.Double), new MySqlParameter("@OpenClose", MySqlDbType.Bit), new MySqlParameter("@DoorTime", MySqlDbType.DateTime), new MySqlParameter("@DoorPhoto", MySqlDbType.VarChar, 100), new MySqlParameter("@Id", MySqlDbType.Int32, 11) }; parameters[0].Value = model.DeliveryId; parameters[1].Value = model.Longitude; parameters[2].Value = model.Latitude; parameters[3].Value = model.OpenClose; parameters[4].Value = model.DoorTime; parameters[5].Value = model.DoorPhoto; parameters[6].Value = model.Id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public YueYePlat.Model.vehicledoors GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,DeliveryId,Longitude,Latitude,OpenClose,DoorTime,DoorPhoto from vehicledoors "); strSql.Append(" where Id=@Id"); MySqlParameter[] parameters = { new MySqlParameter("@Id", MySqlDbType.Int32) }; parameters[0].Value = Id; YueYePlat.Model.vehicledoors model = new YueYePlat.Model.vehicledoors(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }