public IList <AssetUseRefundInfo> GetList() { StringBuilder sb = new StringBuilder(250); sb.Append(@"select UseRefundId,AssetId from AssetUseRefund order by LastUpdatedDate desc " ); IList <AssetUseRefundInfo> list = new List <AssetUseRefundInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AssetConnString, CommandType.Text, sb.ToString())) { if (reader != null && reader.HasRows) { while (reader.Read()) { AssetUseRefundInfo model = new AssetUseRefundInfo(); model.UseRefundId = reader.GetGuid(0); model.AssetId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <AssetUseRefundInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select UseRefundId,AssetId from AssetUseRefund "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } IList <AssetUseRefundInfo> list = new List <AssetUseRefundInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AssetConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { AssetUseRefundInfo model = new AssetUseRefundInfo(); model.UseRefundId = reader.GetGuid(0); model.AssetId = reader.GetGuid(1); list.Add(model); } } } return(list); }
public IList <AssetUseRefundInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber, UseRefundId,AssetId from AssetUseRefund " ); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); IList <AssetUseRefundInfo> list = new List <AssetUseRefundInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AssetConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { AssetUseRefundInfo model = new AssetUseRefundInfo(); model.UseRefundId = reader.GetGuid(1); model.AssetId = reader.GetGuid(2); list.Add(model); } } } return(list); }
public AssetUseRefundInfo GetModel(object UseRefundId) { AssetUseRefundInfo model = null; StringBuilder sb = new StringBuilder(300); sb.Append(@"select top 1 UseRefundId,AssetId from AssetUseRefund where UseRefundId = @UseRefundId " ); SqlParameter parm = new SqlParameter("@UseRefundId", SqlDbType.UniqueIdentifier); parm.Value = Guid.Parse(UseRefundId.ToString()); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AssetConnString, CommandType.Text, sb.ToString(), parm)) { if (reader != null) { if (reader.Read()) { model = new AssetUseRefundInfo(); model.UseRefundId = reader.GetGuid(0); model.AssetId = reader.GetGuid(1); } } } return(model); }
public int Update(AssetUseRefundInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"update AssetUseRefund set AssetId = @AssetId where UseRefundId = @UseRefundId " ); SqlParameter[] parms = { new SqlParameter("@UseRefundId", SqlDbType.UniqueIdentifier), new SqlParameter("@AssetId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.UseRefundId; parms[1].Value = model.AssetId; return(SqlHelper.ExecuteNonQuery(SqlHelper.AssetConnString, CommandType.Text, sb.ToString(), parms)); }
public int Insert(AssetUseRefundInfo model) { StringBuilder sb = new StringBuilder(250); sb.Append(@"insert into AssetUseRefund (UseRefundId,AssetId) values (@UseRefundId,@AssetId) " ); SqlParameter[] parms = { new SqlParameter("@UseRefundId", SqlDbType.UniqueIdentifier), new SqlParameter("@AssetId", SqlDbType.UniqueIdentifier) }; parms[0].Value = model.UseRefundId; parms[1].Value = model.AssetId; return(SqlHelper.ExecuteNonQuery(SqlHelper.AssetConnString, CommandType.Text, sb.ToString(), parms)); }
public IList <AssetUseRefundInfo> GetListByJoin(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms) { StringBuilder sb = new StringBuilder(250); sb.Append(@"select count(*) from UseRefund ur left join AssetUseRefund aur on aur.UseRefundId = ur.Id left join AssetInStore ais on ais.Id = aur.AssetId "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.AssetConnString, CommandType.Text, sb.ToString(), cmdParms); if (totalRecords == 0) { return(new List <AssetUseRefundInfo>()); } sb.Clear(); int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; sb.Append(@"select * from(select row_number() over(order by ur.LastUpdatedDate desc) as RowNumber, ur.Id,ur.UsePerson,ur.UseTime,ur.EstimateRefundTime,ur.UseUser,ur.RealRefundTime,ur.RefundDealUser,ur.Status,ur.Remark ,ais.Id AssetId,ais.Barcode,c.Named CategoryName,ais.Named AssetName,ais.SpecModel,ais.SNCode,ais.Unit,ais.Price,ais.Named OwnedCompanyName ,com.Named UseCompanyName,orgd.Named OrgDepmtName,ais.UsePerson AssetUsePerson,ais.StoreLocation from UseRefund ur left join AssetUseRefund aur on aur.UseRefundId = ur.Id left join AssetInStore ais on ais.Id = aur.AssetId left join Category c on ais.CategoryId = c.Id left join Company com on ais.UseCompanyId = com.Id left join Company com2 on ais.OwnedCompanyId = com2.Id left join OrgDepmt orgd on ais.UseDepmtId = orgd.Id "); if (!string.IsNullOrEmpty(sqlWhere)) { sb.AppendFormat(" where 1=1 {0} ", sqlWhere); } sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex); var list = new List <AssetUseRefundInfo>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AssetConnString, CommandType.Text, sb.ToString(), cmdParms)) { if (reader != null && reader.HasRows) { while (reader.Read()) { var model = new AssetUseRefundInfo(); model.UseRefundId = reader.GetGuid(1); model.UsePerson = reader.GetString(2); model.SUseTime = reader.GetDateTime(3).ToString("yyyy-MM-dd").Replace("1754-01-01", ""); model.SEstimateRefundTime = reader.GetDateTime(4).ToString("yyyy-MM-dd").Replace("1754-01-01", ""); model.UseUserName = reader.GetString(5); model.SRealRefundTime = reader.GetDateTime(6).ToString("yyyy-MM-dd").Replace("1754-01-01", ""); model.RefundDealUserName = reader.GetString(7); model.Status = reader.GetString(8); model.Remark = reader.GetString(9); model.AssetId = reader.IsDBNull(10) ? Guid.Empty : reader.GetGuid(10); model.Barcode = reader.IsDBNull(11) ? "" : reader.GetString(11); model.CategoryName = reader.IsDBNull(12) ? "" : reader.GetString(12); model.AssetName = reader.IsDBNull(13) ? "" : reader.GetString(13); model.SpecModel = reader.IsDBNull(14) ? "" : reader.GetString(14); model.SNCode = reader.IsDBNull(15) ? "" : reader.GetString(15); model.Unit = reader.IsDBNull(16) ? "" : reader.GetString(16); model.Price = reader.IsDBNull(17) ? 0 : reader.GetDecimal(17); model.OwnedCompany = reader.IsDBNull(18) ? "" : reader.GetString(18); model.UseCompany = reader.IsDBNull(19) ? "" : reader.GetString(19); model.UseCompanyDepmt = reader.IsDBNull(20) ? "" : reader.GetString(20); model.AssetUsePerson = reader.IsDBNull(21) ? "" : reader.GetString(21); model.StoreLocation = reader.IsDBNull(22) ? "" : reader.GetString(22); list.Add(model); } } } return(list); }
/// <summary> /// 修改数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(AssetUseRefundInfo model) { return(dal.Update(model)); }
/// <summary> /// 添加数据到数据库 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Insert(AssetUseRefundInfo model) { return(dal.Insert(model)); }