/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.TypeWeightData model) { StringBuilder strBuilder = new StringBuilder(); strBuilder.Append("update T_TypeWeightData set "); strBuilder.Append("Id=" + model.Id + ","); strBuilder.Append("Helicopter_Name='" + model.Helicopter_Name + "',"); strBuilder.Append("Last_ModifyTime='" + model.Last_ModifyTime + "',"); strBuilder.Append("Helicopter_Type='" + model.Helicopter_Type + "',"); strBuilder.Append("DesignTaking_Weight=" + model.DesignTaking_Weight + ","); strBuilder.Append("MaxTaking_Weight=" + model.MaxTaking_Weight + ","); strBuilder.Append("EmptyWeight=" + model.EmptyWeight + ","); strBuilder.Append("MainSystem_Name='" + model.MainSystem_Name + "',"); strBuilder.Append("Helicoter_Country='" + model.Helicoter_Country + "'"); strBuilder.Append(" where Id=" + model.Id.ToString()); int rows = SQLiteDBHelper.ExecuteNonQuery(strBuilder.ToString(), null); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.TypeWeightData model) { StringBuilder strBuilder = new StringBuilder(); strBuilder.Append("insert into T_TypeWeightData("); strBuilder.Append("Id,Helicopter_Name,Last_ModifyTime,Helicopter_Type,DesignTaking_Weight,MaxTaking_Weight,EmptyWeight,MainSystem_Name,Helicoter_Country)"); strBuilder.Append(" values ("); strBuilder.Append("" + model.Id + ","); strBuilder.Append("'" + model.Helicopter_Name + "',"); strBuilder.Append("'" + model.Last_ModifyTime + "',"); strBuilder.Append("'" + model.Helicopter_Type + "',"); strBuilder.Append("" + model.DesignTaking_Weight + ","); strBuilder.Append("" + model.MaxTaking_Weight + ","); strBuilder.Append("" + model.EmptyWeight + ","); strBuilder.Append("'" + model.MainSystem_Name + "',"); strBuilder.Append("'" + model.Helicoter_Country + "'"); strBuilder.Append(")"); int rows = SQLiteDBHelper.ExecuteNonQuery(strBuilder.ToString(), null); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.TypeWeightData DataRowToModel(DataRow row) { Model.TypeWeightData model = new Model.TypeWeightData(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["Helicopter_Name"] != null) { model.Helicopter_Name = row["Helicopter_Name"].ToString(); } if (row["Last_ModifyTime"] != null) { model.Last_ModifyTime = row["Last_ModifyTime"].ToString(); } if (row["Helicopter_Type"] != null) { model.Helicopter_Type = row["Helicopter_Type"].ToString(); } if (row["DesignTaking_Weight"] != null && row["DesignTaking_Weight"].ToString() != "") { model.DesignTaking_Weight = Convert.ToDouble(row["DesignTaking_Weight"]); } if (row["MaxTaking_Weight"] != null && row["MaxTaking_Weight"].ToString() != "") { model.MaxTaking_Weight = Convert.ToDouble(row["MaxTaking_Weight"]); } if (row["EmptyWeight"] != null && row["EmptyWeight"].ToString() != "") { model.EmptyWeight = Convert.ToDouble(row["EmptyWeight"]); } if (row["MainSystem_Name"] != null) { model.MainSystem_Name = row["MainSystem_Name"].ToString(); } if (row["Helicoter_Country"] != null) { model.Helicoter_Country = row["Helicoter_Country"].ToString(); } } return(model); }
/// <summary> /// 获取所有实体 /// </summary> /// <returns></returns> public List <Model.TypeWeightData> GetListModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,Helicopter_Name,Last_ModifyTime,Helicopter_Type,DesignTaking_Weight,MaxTaking_Weight,EmptyWeight,MainSystem_Name,Helicoter_Country from T_TypeWeightData "); List <Model.TypeWeightData> lstWeightData = new List <Model.TypeWeightData>(); DataTable table = SQLiteDBHelper.ExecuteDataTable(strSql.ToString(), null); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { Model.TypeWeightData model = DataRowToModel(table.Rows[i]); lstWeightData.Add(model); } } return(lstWeightData); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.TypeWeightData GetModel(int Id) { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,Helicopter_Name,Last_ModifyTime,Helicopter_Type,DesignTaking_Weight,MaxTaking_Weight,EmptyWeight,MainSystem_Name,Helicoter_Country from T_TypeWeightData "); strSql.Append(" where Id=" + Id.ToString()); Model.TypeWeightData model = new Model.TypeWeightData(); DataTable table = SQLiteDBHelper.ExecuteDataTable(strSql.ToString(), null); if (table.Rows.Count > 0) { return(DataRowToModel(table.Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.TypeWeightData model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Add(Model.TypeWeightData model) { return(dal.Add(model)); }