/// <summary> /// 得到一个对象实体 /// </summary> public DSJL.Model.TB_StandardInfo DataRowToModel(DataRow row) { DSJL.Model.TB_StandardInfo model=new DSJL.Model.TB_StandardInfo(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["Stand_Name"]!=null) { model.Stand_Name=row["Stand_Name"].ToString(); } if(row["Stand_Date"]!=null) { model.Stand_Date=row["Stand_Date"].ToString(); } if(row["Stand_Remark"]!=null) { model.Stand_Remark=row["Stand_Remark"].ToString(); } if(row["Stand_Level"]!=null && row["Stand_Level"].ToString()!="") { model.Stand_Level=int.Parse(row["Stand_Level"].ToString()); } if(row["Stand_ParentID"]!=null && row["Stand_ParentID"].ToString()!="") { model.Stand_ParentID=int.Parse(row["Stand_ParentID"].ToString()); } } return model; }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DSJL.Model.TB_StandardInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TB_StandardInfo("); strSql.Append("Stand_Name,Stand_Date,Stand_Remark,Stand_Level,Stand_ParentID)"); strSql.Append(" values ("); strSql.Append("@Stand_Name,@Stand_Date,@Stand_Remark,@Stand_Level,@Stand_ParentID)"); OleDbParameter[] parameters = { new OleDbParameter("@Stand_Name", OleDbType.VarChar, 255), new OleDbParameter("@Stand_Date", OleDbType.VarChar, 255), new OleDbParameter("@Stand_Remark", OleDbType.VarChar, 255), new OleDbParameter("@Stand_Level", OleDbType.Integer, 4), new OleDbParameter("@Stand_ParentID", OleDbType.Integer, 4) }; parameters[0].Value = model.Stand_Name; parameters[1].Value = model.Stand_Date; parameters[2].Value = model.Stand_Remark; parameters[3].Value = model.Stand_Level; parameters[4].Value = model.Stand_ParentID; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DSJL.Model.TB_StandardInfo DataRowToModel(DataRow row) { DSJL.Model.TB_StandardInfo model = new DSJL.Model.TB_StandardInfo(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["Stand_Name"] != null) { model.Stand_Name = row["Stand_Name"].ToString(); } if (row["Stand_Date"] != null) { model.Stand_Date = row["Stand_Date"].ToString(); } if (row["Stand_Remark"] != null) { model.Stand_Remark = row["Stand_Remark"].ToString(); } if (row["Stand_Level"] != null && row["Stand_Level"].ToString() != "") { model.Stand_Level = int.Parse(row["Stand_Level"].ToString()); } if (row["Stand_ParentID"] != null && row["Stand_ParentID"].ToString() != "") { model.Stand_ParentID = int.Parse(row["Stand_ParentID"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DSJL.Model.TB_StandardInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TB_StandardInfo set "); strSql.Append("Stand_Name=@Stand_Name,"); strSql.Append("Stand_Date=@Stand_Date,"); strSql.Append("Stand_Remark=@Stand_Remark,"); strSql.Append("Stand_Level=@Stand_Level,"); strSql.Append("Stand_ParentID=@Stand_ParentID"); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@Stand_Name", OleDbType.VarChar, 255), new OleDbParameter("@Stand_Date", OleDbType.VarChar, 255), new OleDbParameter("@Stand_Remark", OleDbType.VarChar, 255), new OleDbParameter("@Stand_Level", OleDbType.Integer, 4), new OleDbParameter("@Stand_ParentID", OleDbType.Integer, 4), new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = model.Stand_Name; parameters[1].Value = model.Stand_Date; parameters[2].Value = model.Stand_Remark; parameters[3].Value = model.Stand_Level; parameters[4].Value = model.Stand_ParentID; parameters[5].Value = model.ID; int rows = DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DSJL.Model.TB_StandardInfo GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,Stand_Name,Stand_Date,Stand_Remark,Stand_Level,Stand_ParentID from TB_StandardInfo "); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@ID", OleDbType.Integer, 4) }; parameters[0].Value = ID; DSJL.Model.TB_StandardInfo model = new DSJL.Model.TB_StandardInfo(); DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DSJL.Model.TB_StandardInfo GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select ID,Stand_Name,Stand_Date,Stand_Remark,Stand_Level,Stand_ParentID from TB_StandardInfo "); strSql.Append(" where ID=@ID"); OleDbParameter[] parameters = { new OleDbParameter("@ID", OleDbType.Integer,4) }; parameters[0].Value = ID; DSJL.Model.TB_StandardInfo model=new DSJL.Model.TB_StandardInfo(); DataSet ds=DbHelperOleDb.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }