public static List <Category> GetCategoriesByKpiId(int kpiId) { List <Category> theList = new List <Category>(); Category theData = null; try { CategoriesTableAdapter localAdapter = new CategoriesTableAdapter(); CategoryDS.CategoriesDataTable theTable = localAdapter.GetCategoriesByKpiId(kpiId); if (theTable != null && theTable.Rows.Count > 0) { foreach (CategoryDS.CategoriesRow theRow in theTable) { theData = FillRecord(theRow); theData.ItemsList = theRow.IsitemsNull() ? "" : theRow.items; theList.Add(theData); } } } catch (Exception exc) { log.Error("Error en GetCategoriesByKpiId para kpiId: " + kpiId, exc); throw new ArgumentException(Resources.Categories.MessageErrorGetCategoriesByKpi); } return(theList); }
protected void insertCat_Click(object sender, EventArgs e) { string categ_noua = numeCat.Text; // caut in baza sa vad daca mai exista o categorie cu acelasi nume CategoriesTableAdapter T = new CategoriesTableAdapter(); int? exists = T.SearchCatByName(categ_noua); if (exists == 0) { T.InsertCategorie(categ_noua); alertaSucces.Visible = true; output.Text = "Inserarea a fost realizata cu succes"; categoriiGrid.DataBind(); listaCat.DataBind(); DropDownList1.DataBind(); numeCat.Text = ""; } else { output.Text = "Inserarea a esuat pentru ca aceasta categorie exista deja"; } }
static void Main(string[] args) { using (NorthwindDataSet ds = new NorthwindDataSet()) using (CategoriesTableAdapter tac = new CategoriesTableAdapter()) using (ProductsTableAdapter tap = new ProductsTableAdapter()) { tac.Fill(ds.Categories); tap.Fill(ds.Products); foreach (var item in ds.Categories) { Console.WriteLine("{0} {1} {2}", item.ItemArray); NorthwindDataSet.ProductsRow[] childs = item.GetProductsRows(); foreach (var item2 in childs) { Console.WriteLine("\t{0} {1} {2} {3} ", item2.CategoryID, item2.ProductID, item2.ProductName, item2.UnitPrice); } } } }
public static Category GetCategoryById(string categoryId) { if (string.IsNullOrEmpty(categoryId)) { throw new ArgumentException(Resources.Categories.MessageEmptyCategoryId); } Category theData = null; try { CategoriesTableAdapter localAdapter = new CategoriesTableAdapter(); CategoryDS.CategoriesDataTable theTable = localAdapter.GetCategoryById(categoryId); if (theTable != null && theTable.Rows.Count > 0) { CategoryDS.CategoriesRow theRow = theTable[0]; theData = FillRecord(theRow); } } catch (Exception exc) { log.Error("Error en GetCategoryById para categoryId: " + categoryId, exc); throw new ArgumentException(Resources.Categories.MessageErrorGetCategory); } return(theData); }
public void CopyCategories() { //Processing Categories LogMessage("Reading Categories...", false); CategoriesTableAdapter adapter1 = new CategoriesTableAdapter(); NorthwindDb4o.NorthwindDataSet.CategoriesDataTable table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (NorthwindDb4o.NorthwindDataSet.CategoriesRow row in table1) { LogMessage("Categories: " + row.CategoryID.ToString() + " ...", false); Category c = new Category(); c.CategoryID = row.CategoryID; c.CategoryName = row.CategoryName; c.Description = row.IsDescriptionNull() ? null : row.Description; c.Picture = row.IsPictureNull() ? null : row.Picture; container.Store(c); LogMessage("saved", true); } container.Commit(); long objectCount = Db4oUtil.GetAllInstances(container, typeof(Category)).Count; if (table1.Count == objectCount) LogMessage(table1.Count + " objects saved", true); else LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true); LogMessage("Done with Categories" + Environment.NewLine, true); }
/// <summary> /// Returns a VariablesDataSet, as defined by VariablesDataSet.xsd /// /// In SDSC code, this variable is loaded once, and is stored in an /// Application, or AppServer variable, and queries are run against the stored dataset. /// Other methods in this class are used to query the dataset. /// </summary> /// <param name="networkID"></param> /// <returns></returns> public static VariablesDataset GetVariableDataSet(int networkID) { VariablesDataset ds = new VariablesDataset(); UnitsTableAdapter unitTableAdapter = new UnitsTableAdapter(); VariablesTableAdapter varsTableAdapter = new VariablesTableAdapter(); CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter(); unitTableAdapter.Connection.ConnectionString = Config.ODDB(); varsTableAdapter.Connection.ConnectionString = Config.ODDB(); categoriesTableAdapter.Connection.ConnectionString = Config.ODDB(); try { unitTableAdapter.Fill(ds.Units); varsTableAdapter.Fill(ds.Variables); categoriesTableAdapter.Fill(ds.Categories); } catch (Exception e) { log.Fatal("Cannot retrieve units or variables from database" + e.Message); //+ unitTableAdapter.Connection.DataSource throw new WaterOneFlowServerException("Cannot retrieve units or variables from database", e); } return(ds); }
public override List <Identity> GetAll(NorthwindConfig config, string whereExpression, OleDbParameter[] oleDbParameters) { #region Declarations List <Identity> result = new List <Identity>(); int recordCount = 0; Category dataset = new Category(); #endregion // get the first 11 rows of the changelog using (OleDbConnection connection = new OleDbConnection(config.ConnectionString)) { CategoriesTableAdapter tableAdapter; tableAdapter = new CategoriesTableAdapter(); tableAdapter.Connection = connection; if (string.IsNullOrEmpty(whereExpression)) { recordCount = tableAdapter.Fill(dataset.Categories); } else { recordCount = tableAdapter.FillByWhereClause(dataset.Categories, whereExpression, oleDbParameters); } } foreach (Category.CategoriesRow row in dataset.Categories.Rows) { // use where expression !! result.Add(new Identity(this.EntityName, row.CategoryID.ToString())); } return(result); }
// Populate your datasources for an editing session using the following method. protected override void FillDataSources(XtraReport report, string reportName, bool isDesignActive) { DataSet1 dataSet = (DataSet1)report.GetDataSourceByName("XtraReport1Data"); using (var categoriesTableAdapter = new CategoriesTableAdapter()) using (var productsTableAdapter = new ProductsTableAdapter()) { categoriesTableAdapter.Fill(dataSet.Categories); productsTableAdapter.Fill(dataSet.Products); } }
public static Northwind CreateNorthwindData() { var northwind = new Northwind(); using (var categoriesAdapter = new CategoriesTableAdapter()) using (var productsAdapter = new ProductsTableAdapter()) { categoriesAdapter.Fill(northwind.Categories); productsAdapter.Fill(northwind.Products); } return(northwind); }
/// <summary> /// Add catagories for each one of the variableID's /// </summary> /// <param name="ds"></param> /// <returns></returns> public static void GetCategories(VariablesDataset ds) { if (ds != null) { CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter(); ds.Categories.Clear(); //foreach (VariablesRow vRow in ds.Variables.Rows) //{ // categoriesTableAdapter.FillByVariableID(ds.Categories, vRow.VariableID); //} } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DrillDownDataSet ddds = new DrillDownDataSet(); CategoriesTableAdapter cta = new CategoriesTableAdapter(); cta.Fill(ddds.Categories); Session["DrillDownDataSet"] = ddds; Session["detailsLevel"] = 0; ShowCategories(); } }
void DesignMdiController_DesignPanelLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e) { // Get access to an instanse of the IToolboxService interface IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService)); // Get access to the collection of the toolbox items ToolboxItemCollection collection = ts.GetToolboxItems(); foreach (ToolboxItem item in collection) { if (item.DisplayName == "Label") { // Change name of the report control collection[0].DisplayName = "Report Label"; } } IDesignerHost host = e.DesignerHost; nwindDataSet ds = new nwindDataSet(); // Search DataSet component foreach (IComponent comp in host.Container.Components) { ds = comp as nwindDataSet; if (!Object.Equals(ds, null)) { // Delete data source from designer host host.Container.Remove(ds); break; } } // In this place you can define your own report data source host.Container.Add(ds, "ReportDataSource"); CategoriesTableAdapter adapter = new CategoriesTableAdapter(); // Search TableAdapter component foreach (IComponent comp in host.Container.Components) { adapter = comp as CategoriesTableAdapter; if (!Object.Equals(adapter, null)) { // Delete table adapter from designer host host.Container.Remove(adapter); break; } } // In this place you can define your own report table adapter host.Container.Add(adapter, "ReportTableAdapter"); }
protected nwndDataSet GetData() { if ((nwndDataSet)Session["dataset"] == null) { nwndDataSet ds = new nwndDataSet(); CategoriesTableAdapter cta = new CategoriesTableAdapter(); ProductsTableAdapter pta = new ProductsTableAdapter(); cta.Fill(ds.Categories); pta.Fill(ds.Products); Session["dataset"] = ds; } return((nwndDataSet)Session["dataset"]); }
public static void DeleteCategory(string categoryId) { if (string.IsNullOrEmpty(categoryId)) { throw new ArgumentException(Resources.Categories.MessageEmptyCategoryId); } try { CategoriesTableAdapter localAdapter = new CategoriesTableAdapter(); localAdapter.DeleteCategory(categoryId); } catch (Exception exc) { log.Error("Error en DeleteCategory para categoryId: " + categoryId, exc); throw new Exception(Resources.Categories.MessageErrorDeleteCategory); } }
protected void Application_Start(object sender, EventArgs e) { var dataSet1 = new DataSet1(); using (var categoriesAdapter = new CategoriesTableAdapter()) { categoriesAdapter.Fill(dataSet1.Categories); var categoriesProvider = new ObjectDataProvider(dataSet1); DataProviderRepository.Current.Register("Categories", "Categories", categoriesProvider); } var dataSet2 = new DataSet2(); using (var customersAdapter = new CustomersTableAdapter()) { customersAdapter.Fill(dataSet2.Customers); var customersProvider = new ObjectDataProvider(dataSet2); DataProviderRepository.Current.Register("Customers", "Customers", customersProvider); } }
static object CreateDataSource() { var dataSource = new nwindDataSet(); var connection = new OleDbConnection(); connection.ConnectionString = Properties.Settings.Default.nwindConnectionString; CategoriesTableAdapter categories = new CategoriesTableAdapter(); categories.Connection = connection; categories.Fill(dataSource.Categories); ProductsTableAdapter products = new ProductsTableAdapter(); products.Connection = connection; products.Fill(dataSource.Products); return(dataSource); }
private void CopyCategories(IOdb odb) { //Processing Categories LogMessage("Reading Categories...", false); var adapter1 = new CategoriesTableAdapter(); var table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (var row in table1) { LogMessage("Categories: " + row.CategoryID.ToString() + " ...", false); var c = new Category { CategoryID = row.CategoryID, CategoryName = row.CategoryName, Description = row.IsDescriptionNull() ? null : row.Description, Picture = row.IsPictureNull() ? null : row.Picture }; odb.Store(c); LogMessage("saved", true); } odb.Commit(); LogMessage("Commit done, starting create index ...", false); odb.IndexManagerFor <Category>().AddUniqueIndexOn("Category_CategoryID_PK_index", Category.PK); odb.Commit(); LogMessage(" index created.", true); long objectCount = NDbUtil.GetAllInstances <Category>(odb).Count; if (table1.Count == objectCount) { LogMessage(table1.Count + " objects saved", true); } else { LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true); } LogMessage("Done with Categories" + Environment.NewLine, true); }
private static void Main() { var dataSet = new NorthwindDataSet(); var tblAdapter = new ProductsTableAdapter(); tblAdapter.Fill(dataSet.Products); var tblAdapterCategories = new CategoriesTableAdapter(); tblAdapterCategories.Fill(dataSet.Categories); foreach (var row in dataSet.Products) { Console.WriteLine($"{row.ProductName}"); } var peterProduct = dataSet.Products.FirstOrDefault(x => x.ProductName == "Peter"); var gabrielProduct = dataSet.Products.FirstOrDefault(x => x.ProductName == "Gabriel"); if (gabrielProduct == default(NorthwindDataSet.ProductsRow) && peterProduct == default(NorthwindDataSet.ProductsRow)) { var newRow = dataSet.Products.NewProductsRow(); newRow.ProductName = "Gabriel"; newRow.Discontinued = false; newRow.CategoriesRow = dataSet.Categories.First(); dataSet.Products.AddProductsRow(newRow); } else if (peterProduct == default(NorthwindDataSet.ProductsRow)) { gabrielProduct.BeginEdit(); gabrielProduct.ProductName = "Peter"; gabrielProduct.EndEdit(); } else if (gabrielProduct == default(NorthwindDataSet.ProductsRow)) { peterProduct.Delete(); } tblAdapter.Update(dataSet); Console.ReadLine(); }
public override Document GetDocument(Identity identity, Token lastToken, NorthwindConfig config) { int recordCount; Category category = new Category(); int id = Identity.GetId(identity); using (OleDbConnection connection = new OleDbConnection(config.ConnectionString)) { CategoriesTableAdapter tableAdapter; tableAdapter = new CategoriesTableAdapter(); tableAdapter.Connection = connection; recordCount = tableAdapter.FillBy(category.Categories, id); } if (recordCount == 0) { return(GetDeletedDocument(identity)); } return(GetDocument((Category.CategoriesRow)category.Categories[0], lastToken, config)); }
public static void InsertCategory(string categoryId, string name) { if (string.IsNullOrEmpty(categoryId)) { throw new ArgumentException(Resources.Categories.MessageEmptyCategoryId); } if (string.IsNullOrEmpty(name)) { throw new ArgumentException(Resources.Categories.MessageEmptyNameCategory); } try { CategoriesTableAdapter localAdapter = new CategoriesTableAdapter(); localAdapter.InsertCategory(name, categoryId); } catch (Exception exc) { log.Error("Error en InsertCategory para los datos categoryId: " + categoryId + " y name: " + name, exc); throw new ArgumentException(Resources.Categories.MessageErrorCreateCategory); } }
public static string GetNameCategoryById(int id) { var categoriesTableAdapter = new CategoriesTableAdapter(); categoriesTableAdapter.Connection.ConnectionString = WssConnection.ConnectionIndividual; var categoriesDataTable = new DBIndi.CategoriesDataTable(); try { categoriesTableAdapter.FillById(categoriesDataTable, id); if (categoriesDataTable.Rows.Count > 0) { return(categoriesDataTable.Rows[0]["Name"].ToString()); } else { return(""); } } catch (Exception) { return(""); } }
public void ProcessRequest(HttpContext context) { _context = context; _req = context.Request; _res = context.Response; if (!string.IsNullOrEmpty(_req.QueryString["t"])) { switch (_req.QueryString["t"].ToLower()) { case "categories": if (!string.IsNullOrEmpty(_req.QueryString["id"])) { cata = new CategoriesTableAdapter(); var ds = new NorthwindDataSet(); cata.FillByCategoryID(ds.Categories, int.Parse(_req.QueryString["id"])); foreach (var item in ds.Categories) { item.Picture = null; } _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else { cata = new CategoriesTableAdapter(); var ds = new NorthwindDataSet(); cata.Fill(ds.Categories); foreach (var item in ds.Categories) { item.Picture = null; } _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } return; case "products": if (!string.IsNullOrEmpty(_req.QueryString["id"])) { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.FillByProductID(ds.Products, int.Parse(_req.QueryString["id"])); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else if (!string.IsNullOrEmpty(_req.QueryString["cid"])) { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.FillByCategoryID(ds.Products, int.Parse(_req.QueryString["cid"])); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } else { prta = new ProductsTableAdapter(); var ds = new NorthwindDataSet(); prta.Fill(ds.Products); _res.ContentType = "text/xml"; _res.ContentEncoding = Encoding.UTF8; _res.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); ds.WriteXml(_res.OutputStream); } return; default: break; } } }
/// <summary> /// Returns a VariablesDataSet, as defined by VariablesDataSet.xsd /// /// In SDSC code, this variable is loaded once, and is stored in an /// Application, or AppServer variable, and queries are run against the stored dataset. /// Other methods in this class are used to query the dataset. /// </summary> /// <param name="networkID"></param> /// <returns></returns> public static VariablesDataset GetVariableDataSet(int networkID) { VariablesDataset ds = new VariablesDataset(); UnitsTableAdapter unitTableAdapter = new UnitsTableAdapter(); VariablesTableAdapter varsTableAdapter = new VariablesTableAdapter(); CategoriesTableAdapter categoriesTableAdapter = new CategoriesTableAdapter(); unitTableAdapter.Connection.ConnectionString = Config.ODDB(); varsTableAdapter.Connection.ConnectionString = Config.ODDB(); categoriesTableAdapter.Connection.ConnectionString = Config.ODDB(); try { unitTableAdapter.Fill(ds.Units); varsTableAdapter.Fill(ds.Variables); categoriesTableAdapter.Fill(ds.Categories); } catch (Exception e) { log.Fatal("Cannot retrieve units or variables from database" + e.Message); //+ unitTableAdapter.Connection.DataSource throw new WaterOneFlowServerException("Cannot retrieve units or variables from database", e); } return ds; }
public List<Category> GetListCategories() { List<Category> categories = new List<Category>(); //Dictionary<int, string> categories = new Dictionary<int, string>(); CategoriesTableAdapter adapter = new CategoriesTableAdapter(); PostAroundMeDataSet.CategoriesDataTable dt = new PostAroundMeDataSet.CategoriesDataTable(); if (System.Web.HttpRuntime.Cache["Categories"] == null) { dt = adapter.GetAllCategories(); System.Web.HttpRuntime.Cache.Insert("Categories", dt, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10)); } else { dt = System.Web.HttpRuntime.Cache["Categories"] as PostAroundMeDataSet.CategoriesDataTable; } categories = CategoryTranslator(dt); // CategoryDtToDictionaryTranslator(dt); return categories; }
private void CopyCategories(IOdb odb) { //Processing Categories LogMessage("Reading Categories...", false); var adapter1 = new CategoriesTableAdapter(); var table1 = adapter1.GetData(); LogMessage("processing " + table1.Count.ToString() + " rows", true); foreach (var row in table1) { LogMessage("Categories: " + row.CategoryID.ToString() + " ...", false); var c = new Category { CategoryID = row.CategoryID, CategoryName = row.CategoryName, Description = row.IsDescriptionNull() ? null : row.Description, Picture = row.IsPictureNull() ? null : row.Picture }; odb.Store(c); LogMessage("saved", true); } odb.Commit(); LogMessage("Commit done, starting create index ...", false); odb.IndexManagerFor<Category>().AddUniqueIndexOn("Category_CategoryID_PK_index", Category.PK); odb.Commit(); LogMessage(" index created.", true); long objectCount = NDbUtil.GetAllInstances<Category>(odb).Count; if (table1.Count == objectCount) LogMessage(table1.Count + " objects saved", true); else LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true); LogMessage("Done with Categories" + Environment.NewLine, true); }