public List <Model_StatRes_Doc> DataTableToList(DataTable dt) { List <Model_StatRes_Doc> list = new List <Model_StatRes_Doc>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Model_StatRes_Doc item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
public bool Add(Model_StatRes_Doc model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into StatRes_Doc("); builder.Append("ID,SYear,SDocType,SDocTypeName,SProductionCount,SDownloadCount,SSaleCount,CreateTime)"); builder.Append(" values ("); builder.Append("@ID,@SYear,@SDocType,@SDocTypeName,@SProductionCount,@SDownloadCount,@SSaleCount,@CreateTime)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.Char, 0x24), new SqlParameter("@SYear", SqlDbType.Int, 4), new SqlParameter("@SDocType", SqlDbType.Char, 0x24), new SqlParameter("@SDocTypeName", SqlDbType.NVarChar, 100), new SqlParameter("@SProductionCount", SqlDbType.Int, 4), new SqlParameter("@SDownloadCount", SqlDbType.Int, 4), new SqlParameter("@SSaleCount", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime) }; cmdParms[0].Value = model.ID; cmdParms[1].Value = model.SYear; cmdParms[2].Value = model.SDocType; cmdParms[3].Value = model.SDocTypeName; cmdParms[4].Value = model.SProductionCount; cmdParms[5].Value = model.SDownloadCount; cmdParms[6].Value = model.SSaleCount; cmdParms[7].Value = model.CreateTime; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public Model_StatRes_Doc DataRowToModel(DataRow row) { Model_StatRes_Doc doc = new Model_StatRes_Doc(); if (row != null) { if (row["ID"] != null) { doc.ID = row["ID"].ToString(); } if ((row["SYear"] != null) && (row["SYear"].ToString() != "")) { doc.SYear = new int?(int.Parse(row["SYear"].ToString())); } if (row["SDocType"] != null) { doc.SDocType = row["SDocType"].ToString(); } if (row["SDocTypeName"] != null) { doc.SDocTypeName = row["SDocTypeName"].ToString(); } if ((row["SProductionCount"] != null) && (row["SProductionCount"].ToString() != "")) { doc.SProductionCount = new int?(int.Parse(row["SProductionCount"].ToString())); } if ((row["SDownloadCount"] != null) && (row["SDownloadCount"].ToString() != "")) { doc.SDownloadCount = new int?(int.Parse(row["SDownloadCount"].ToString())); } if ((row["SSaleCount"] != null) && (row["SSaleCount"].ToString() != "")) { doc.SSaleCount = new int?(int.Parse(row["SSaleCount"].ToString())); } if ((row["CreateTime"] != null) && (row["CreateTime"].ToString() != "")) { doc.CreateTime = new DateTime?(DateTime.Parse(row["CreateTime"].ToString())); } } return(doc); }
public bool Update(Model_StatRes_Doc model) { StringBuilder builder = new StringBuilder(); builder.Append("update StatRes_Doc set "); builder.Append("SYear=@SYear,"); builder.Append("SDocType=@SDocType,"); builder.Append("SDocTypeName=@SDocTypeName,"); builder.Append("SProductionCount=@SProductionCount,"); builder.Append("SDownloadCount=@SDownloadCount,"); builder.Append("SSaleCount=@SSaleCount,"); builder.Append("CreateTime=@CreateTime"); builder.Append(" where ID=@ID "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@SYear", SqlDbType.Int, 4), new SqlParameter("@SDocType", SqlDbType.Char, 0x24), new SqlParameter("@SDocTypeName", SqlDbType.NVarChar, 100), new SqlParameter("@SProductionCount", SqlDbType.Int, 4), new SqlParameter("@SDownloadCount", SqlDbType.Int, 4), new SqlParameter("@SSaleCount", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.Char, 0x24) }; cmdParms[0].Value = model.SYear; cmdParms[1].Value = model.SDocType; cmdParms[2].Value = model.SDocTypeName; cmdParms[3].Value = model.SProductionCount; cmdParms[4].Value = model.SDownloadCount; cmdParms[5].Value = model.SSaleCount; cmdParms[6].Value = model.CreateTime; cmdParms[7].Value = model.ID; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public bool Add(Model_StatRes_Doc model) { return(this.dal.Add(model)); }
public bool Update(Model_StatRes_Doc model) { return(this.dal.Update(model)); }