public DataTable PopulateGrid(IPopulate ipopulate) { string sqlCommand = ""; DbCommand dbCommand; DataTable dt = new DataTable(); Database db = DatabaseFactory.CreateDatabase("SUPPORTTICKETS"); sqlCommand = "ProCmnGetRecordsPopup"; dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "@TableName", DbType.String, ipopulate.TableName); db.AddInParameter(dbCommand, "@ListFields", DbType.String, ipopulate.ListFields); db.AddInParameter(dbCommand, "@SortField", DbType.String, ipopulate.SortFields); db.AddInParameter(dbCommand, "@Criteria", DbType.String, ipopulate.Criteria); db.AddInParameter(dbCommand, "@Criteria2", DbType.String, ipopulate.Criteria2); db.AddInParameter(dbCommand, "@Groupby", DbType.String, ipopulate.GroupBy); db.AddInParameter(dbCommand, "@RowId", DbType.String, ipopulate.ValueFields); db.AddInParameter(dbCommand, "@PageIndex", DbType.Int16, ipopulate.PageIndex); db.AddInParameter(dbCommand, "@PageSize", DbType.Int16, ipopulate.PageSize); try { DataSet ds = new DataSet(); ds = db.ExecuteDataSet(dbCommand); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; } return(dt); } catch (Exception e) { throw; } }
public DataTable PopulateDataTwoFields(IPopulate ipopulate) { string sqlCommand = ""; DbCommand dbCommand; DataTable dt = new DataTable(); Database db = DatabaseFactory.CreateDatabase("SUPPORTTICKETS"); sqlCommand = "proCmnPopulate2Data"; dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "TableName", DbType.String, ipopulate.TableName); db.AddInParameter(dbCommand, "ListField", DbType.String, ipopulate.ListFields + ((ipopulate.ValueFields.Trim().Length <= 0) ? "" : "," + ipopulate.ValueFields)); db.AddInParameter(dbCommand, "ListField2", DbType.String, ipopulate.ListFields2 + ((ipopulate.ValueFields2.Trim().Length <= 0) ? "" : "," + ipopulate.ValueFields2)); db.AddInParameter(dbCommand, "SortField", DbType.String, ipopulate.SortFields); db.AddInParameter(dbCommand, "Criteria", DbType.String, ipopulate.Criteria); try { DataSet ds = new DataSet(); ds = db.ExecuteDataSet(dbCommand); if (ds.Tables.Count > 0) { dt = ds.Tables[0]; } return(dt); } catch (Exception e) { throw; } }
//DataTable public DataTable GetDataTable(IPopulate ipopulate) { DataTable dt = new DataTable(); Database db = DatabaseFactory.CreateDatabase("SUPPORTTICKETS"); string sqlCommand = "ProCmnGetRecords"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "TableName", DbType.String, ipopulate.TableName); db.AddInParameter(dbCommand, "ListFields", DbType.String, ipopulate.ListFields); db.AddInParameter(dbCommand, "SortField", DbType.String, ipopulate.SortFields); db.AddInParameter(dbCommand, "Criteria", DbType.String, ipopulate.Criteria); DataSet ds = new DataSet(); try { ds = db.ExecuteDataSet(dbCommand); if (ds.Tables.Count > 0) { return(ds.Tables[0]); } else { return(dt); } } catch (Exception e) { string errdetails = "exec ProCmnGetRecords '" + ipopulate.TableName + "','" + ipopulate.ListFields + ((ipopulate.ListFields.Length <= 0) ? "" : "," + ipopulate.ValueFields) + "','" + ipopulate.SortFields + "','" + ipopulate.Criteria + "'"; } return(ds.Tables[0]); }
public ArrayList GetArrayList(IPopulate ipopulate) { ArrayList arlist = new ArrayList(); Database db = DatabaseFactory.CreateDatabase("SUPPORTTICKETS"); string sqlCommand = "ProCmnGetRecords"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "TableName", DbType.String, ipopulate.TableName); db.AddInParameter(dbCommand, "ListFields", DbType.String, ipopulate.ListFields); db.AddInParameter(dbCommand, "SortField", DbType.String, ipopulate.SortFields); db.AddInParameter(dbCommand, "Criteria", DbType.String, ipopulate.Criteria); try { DataSet ds = new DataSet(); ds = db.ExecuteDataSet(dbCommand); IDataReader datareader = ds.Tables[0].CreateDataReader(); ds = null; while (datareader.Read()) { for (int i = 0; i < datareader.FieldCount; i++) { arlist.Add(datareader.GetValue(i)); } } datareader = null; } catch (Exception e) { string errdetails = "exec ProCmnGetRecords '" + ipopulate.TableName + "','" + ipopulate.ListFields + ((ipopulate.ListFields.Length <= 0) ? "" : "," + ipopulate.ValueFields) + "','" + ipopulate.SortFields + "','" + ipopulate.Criteria + "'"; //UpdateErrorLog(ipopulate, errdetails, e); errdetails = null; throw; } return(arlist); }
public DataController(IPopulate populate, ExportTemplate migrate) { pop = populate; mig = migrate; }