public PagedList<QRCode> GetQRList(int pageIndex, int pageSize) { var qrList = new List<QRCode>(); var count = 0; using (var cmd = DataCommandManager.GetDataCommand("GetQRListByPage")) { cmd.SetParameterValue("@PageIndex", pageIndex); cmd.SetParameterValue("@PageSize", pageSize); using (var ds = cmd.ExecuteDataSet()) { if (ds.Tables.Count >= 2) { foreach (DataRow dr in ds.Tables[0].Rows) { var qrcode = new QRCode(); qrcode.Id = !Convert.IsDBNull(dr["Id"]) ? int.Parse(dr["Id"].ToString()) : 0; qrcode.SourceCode = !Convert.IsDBNull(dr["SourceCode"]) ? dr["SourceCode"].ToString() : string.Empty; qrcode.SourceName = !Convert.IsDBNull(dr["SourceName"]) ? dr["SourceName"].ToString() : string.Empty; qrcode.QRCodeUrl = !Convert.IsDBNull(dr["QRCodeUrl"]) ? dr["QRCodeUrl"].ToString() : string.Empty; qrcode.Status = !Convert.IsDBNull(dr["Status"]) ? int.Parse(dr["Status"].ToString()) : 0; qrcode.CreateTime = !Convert.IsDBNull(dr["CreateTime"]) ? Convert.ToDateTime(dr["CreateTime"]) : DateTime.MinValue; qrcode.SourceCount = !Convert.IsDBNull(dr["SourceCount"]) ? int.Parse(dr["SourceCount"].ToString()) : 0; qrList.Add(qrcode); } var countDr = ds.Tables[1].Rows[0][0]; count = !Convert.IsDBNull(countDr) ? Convert.ToInt32(countDr) : 0; } } var result = new PagedList<QRCode>(qrList, pageIndex, pageSize, count); return result; } }
public int InsertQRCode(QRCode qr) { return userDataAccess.InsertQRCode(qr); }
public int InsertQRCode(QRCode qr) { using (var cmd = DataCommandManager.GetDataCommand("InsertQRCode")) { cmd.SetParameterValue("@QRCodeUrl", qr.QRCodeUrl); cmd.SetParameterValue("@SourceCode", qr.SourceCode); cmd.SetParameterValue("@SourceName", qr.SourceName); cmd.SetParameterValue("@Status", qr.Status); cmd.SetParameterValue("@CreateTime", qr.CreateTime); var result = cmd.ExecuteScalar(); if (result != null) { return Convert.ToInt32(result); } return 0; } }