static void Main(string[] args) { var shopDB = new ShopDB(); var customerRow = shopDB.Customers.NewRow(); //simple dataRow customerRow[0] = 1; customerRow[1] = "Aleksey"; customerRow[2] = "Petrov"; customerRow[3] = "Nikolaevich"; customerRow[4] = "Lujnaya 7"; customerRow[5] = DBNull.Value; customerRow[6] = "Kiev"; customerRow[7] = "(095)4578596"; customerRow[8] = "2009/09/18"; shopDB.Customers.Rows.Add(customerRow); foreach (DataRow row in shopDB.Customers.Rows) { foreach (DataColumn column in shopDB.Customers.Columns) { Console.WriteLine($"{column.ColumnName}: {row[column]}"); } } Console.ReadKey(); }
private void Form1_Load(object sender, EventArgs e) { ShopDB shopDB = new ShopDB(); var employeesTableAdapter = new ShopDBTableAdapters.EmployeesTableAdapter(); employeesTableAdapter.Fill(shopDB.Employees); var ordersTableAdapter = new ShopDBTableAdapters.OrdersTableAdapter(); ordersTableAdapter.Fill(shopDB.Orders); ShopDB.EmployeesDataTable employees = employeesTableAdapter.GetData(); ShopDB.OrdersDataTable orders = ordersTableAdapter.GetData(); employees.Columns.Add("Count", typeof(int)); foreach (DataRow employeeRow in employees.Rows) { employeeRow["Count"] = orders.Count(o => o.EmployeeID == (int)employeeRow["EmployeeID"]); } dataGridView1.DataSource = employees; this.dataGridView1.Columns["FName"].Visible = false; this.dataGridView1.Columns["LName"].Visible = false; this.dataGridView1.Columns["MName"].Visible = false; this.dataGridView1.Columns["Salary"].Visible = false; this.dataGridView1.Columns["PriorSalary"].Visible = false; this.dataGridView1.Columns["HireDate"].Visible = false; this.dataGridView1.Columns["TerminationDate"].Visible = false; this.dataGridView1.Columns["ManagerEmpID"].Visible = false; //// }
public ActionResult EditPut(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShopDB db = new ShopDB(); var productToUpdate = db.Products.Find(id); if (TryUpdateModel(productToUpdate, "", new string[] { "ProductName", "ProductPrice", "ProductDescription", "ProductImg", "CategoryId" })) { try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception dex) { db.Logs.Add(new Log { LogDesc = dex.ToString() }); } } return(View(productToUpdate)); }
static void Main(string[] args) { ShopDB shopDB = new ShopDB(); // создание строготипизированного DataSet DataRow customersRow = shopDB.Customers.NewRow(); // Создание новой строки. Тип DataRow // заполнение полей строки данными customersRow[0] = 1; customersRow[1] = "Алексей"; customersRow[2] = "Петров"; customersRow[3] = "Николаевич"; customersRow[4] = "Лужная 7"; customersRow[5] = DBNull.Value; customersRow[6] = "Киев"; customersRow[7] = "(096)4578596"; customersRow[8] = "2009/09/18"; // добавление строки в коллекцию строк таблицы shopDB.Customers.Rows.Add(customersRow); // вывод данных на экран foreach (DataRow row in shopDB.Customers.Rows) { foreach (DataColumn column in shopDB.Customers.Columns) { Console.WriteLine("{0}: {1}", column.ColumnName, row[column]); } } }
static void Main(string[] args) { var shopDB = new ShopDB(); new CustomersTableAdapter().Fill(shopDB.Customers); new OrdersTableAdapter().Fill(shopDB.Orders); new OrderDetailsTableAdapter().Fill(shopDB.OrderDetails); new ProductsTableAdapter().Fill(shopDB.Products); foreach (ShopDB.CustomersRow customer in shopDB.Customers) { var orders = customer.GetOrdersRows(); if (orders.Length > 0) //if customer has ordered anything { Console.WriteLine($"{customer.LName} {customer.FName} {customer.MName}"); Console.WriteLine(); foreach (ShopDB.OrdersRow order in orders) { Console.WriteLine($"\tOrderID: {order.OrderID}, {order.OrderDate}"); foreach (ShopDB.OrderDetailsRow orderDetail in order.GetOrderDetailsRows()) { var product = orderDetail.ProductsRow; Console.WriteLine($"\t\tLine: {orderDetail.LineItem} - {product.Description.Trim()}, {orderDetail.TotalPrice:C}"); } Console.WriteLine(); } } } Console.ReadKey(); }
static void Main(string[] args) { var simpleShopDB = new DataSet(); simpleShopDB.ReadXmlSchema(@"C:\Users\HP\Desktop\Test\ShopDbSchema.xml"); simpleShopDB.ReadXml(@"C:\Users\HP\Desktop\Test\ShopDBData.xml"); var strongShopDB = new ShopDB(); strongShopDB.Customers.Merge(simpleShopDB.Tables["Customers"]); strongShopDB.AcceptChanges(); var selectedCustomer = strongShopDB.Customers.FindByCustomerNo(1); selectedCustomer.Phone = "testValue"; DataSet dataSetWithChanges = strongShopDB.GetChanges(); //returns dataset with all the changes made on strongshopdb var instance = dataSetWithChanges as ShopDB; //we can downcast data set to shopdb as shopdb is a dataset foreach (DataRow row in dataSetWithChanges.Tables["Customers"].Rows) { foreach (DataColumn column in dataSetWithChanges.Tables["Customers"].Columns) { Console.WriteLine($"{column.ColumnName}: {row[column]}"); } } Console.ReadKey(); }
static void Main(string[] args) { ShopDB shopDB = new ShopDB(); // создание строки для таблицы Customers ShopDB.CustomersRow customersRow = shopDB.Customers.NewCustomersRow(); // Для заполнения полей строки используются строготипизированные свойства customersRow.FName = "Алексей"; customersRow.LName = "Петров"; customersRow.MName = "Николаевич"; customersRow.Address1 = "Лужная 7"; customersRow.Address2 = null; customersRow.City = "Киев"; customersRow.Phone = "(096)4578596"; customersRow.DateInSystem = new DateTime(2009, 09, 18); // добавление созданной строки в коллекцию строк таблицы shopDB.Customers.Rows.Add(customersRow); // еще один способ добавления строки в соллекцию строк таблицы shopDB.Customers.AddCustomersRow("Николай", "Александров", "Анатольевич", "Московская 15", null, "Чернигов", "(063)0215478", new DateTime(2008, 05, 15)); foreach (DataRow row in shopDB.Customers.Rows) { foreach (DataColumn column in shopDB.Customers.Columns) { Console.WriteLine("{0}: {1}", column.ColumnName, row[column]); } Console.WriteLine(); } }
protected override List <ButtonData> CreateMyButtonData() { var itemData = (ItemDBData)UIController.Instance.GetFlashData_static("item"); var result = new List <ButtonData>(); int maxNum = ShopDB.GetBuyableCount(itemData); for (int i = 1; i <= maxNum; i++) { UnityEvent click = new UnityEvent(); int num = i; click.AddListener(() => { UIController.Instance.SetFlashData("num", num.ToString()); UIController.Instance.SetFlashData("item", itemData); _MyUIBase.AddUI(_nextUI); }); var price = itemData._data._price * i; Action cursor = () => { _priceText.text = $"{price}G"; }; var add = new ButtonData(i.ToString(), click, cursor, ButtonData.ButtonType.Selectable); result.Add(add); } return(result); }
static void Main(string[] args) { ShopDB shopDB = new ShopDB(); var employeesTableAdapter = new ShopDBTableAdapters.EmployeesTableAdapter(); employeesTableAdapter.Fill(shopDB.Employees); var ordersTableAdapter = new ShopDBTableAdapters.OrdersTableAdapter(); ordersTableAdapter.Fill(shopDB.Orders); var orderDetailsTableAdapter = new ShopDBTableAdapters.OrderDetailsTableAdapter(); orderDetailsTableAdapter.Fill(shopDB.OrderDetails); ShopDB.EmployeesDataTable employees = employeesTableAdapter.GetData(); ShopDB.OrdersDataTable orders = ordersTableAdapter.GetData(); employees.Columns.Add("Count", typeof(int)); foreach (DataRow employeeRow in employees.Rows) { employeeRow["Count"] = orders.Count(o => o.EmployeeID == (int)employeeRow["EmployeeID"]); foreach (DataColumn column in employees.Columns) { if (column.ColumnName == "EmployeeID" || column.ColumnName == "Count") { Console.WriteLine("{0}: {1}", column.ColumnName, employeeRow[column]); } } Console.WriteLine(); } }
static void Main(string[] args) { ShopDB shopDB = new ShopDB(); ShopDB.CustomersRow customersRow = shopDB.Customers.NewCustomersRow(); shopDB.Customers.AddCustomersRow("Николай", "Александров", "Анатольевич", "Московская 15", null, "Чернигов", "(063)0215478", new DateTime(2008, 05, 15)); shopDB.Customers.AddCustomersRow("Константин", "Нимазов", "Алексеевич", "Октябрьская 5", null, "Киев", "(093)5487478", new DateTime(2009, 06, 20)); shopDB.Customers.AddCustomersRow("Андрей", "Макин", "Абрамович", "Сеновальная 7", null, "Витебск", "(098)7123478", new DateTime(2006, 12, 1)); var selectedCustomer = shopDB.Customers.FindByCustomerNo(-3); selectedCustomer.BeginEdit(); selectedCustomer.SetMNameNull(); // присвоение полю строки значния DbNull.Value selectedCustomer.EndEdit(); Console.WriteLine("Last name: " + selectedCustomer.LName); Console.WriteLine("First name: " + selectedCustomer.FName); if (selectedCustomer.IsMNameNull()) // проверка на DbNull.Value { Console.WriteLine("Middle name: no data"); } else { Console.WriteLine("Middle name: " + selectedCustomer.MName); } Console.WriteLine("Phone: " + selectedCustomer.Phone); }
static void Main(string[] args) { DataSet simpleShopDb = new DataSet(); simpleShopDb.ReadXmlSchema(@"D:\ADO.NET\DATA\ShopDbSchema.xml"); simpleShopDb.ReadXml(@"D:\ADO.NET\DATA\ShopDBData.xml"); ShopDB strongedShopDB = new ShopDB(); strongedShopDB.Customers.Merge(simpleShopDb.Tables["Customers"]); strongedShopDB.AcceptChanges(); var selectedCustomer = strongedShopDB.Customers.FindByCustomerNo(1); selectedCustomer.Phone = "New Value"; // Метод GetChanes() получает копию класса DataSet, содержащую все изменения, внесенные после его последней загрузки или после вызова метода AcceptChanges. DataSet datasetWithChanges = strongedShopDB.GetChanges(); ShopDB inst = datasetWithChanges as ShopDB; foreach (DataRow row in datasetWithChanges.Tables["Customers"].Rows) { foreach (DataColumn column in datasetWithChanges.Tables["Customers"].Columns) { Console.WriteLine("{0}: {1}", column.ColumnName, row[column]); } } }
private void Form1_Load(object sender, EventArgs e) { ShopDB shopDB = new ShopDB(); var customersTableAdapter = new ShopDBTableAdapters.CustomersTableAdapter(); customersTableAdapter.Fill(shopDB.Customers); var ordersTableAdapter = new ShopDBTableAdapters.OrdersTableAdapter(); ordersTableAdapter.Fill(shopDB.Orders); var employeesTableAdapter = new ShopDBTableAdapters.EmployeesTableAdapter(); // employeesTableAdapter.Fill(shopDB.Employees); shopDB.Orders.Columns.Add("SurnameEmployee", typeof(String)); shopDB.Orders.Columns.Add("NameEmployee", typeof(String)); shopDB.Orders.Columns.Add("SurnameCustomer", typeof(String)); shopDB.Orders.Columns.Add("NameCustomer", typeof(String)); foreach (var orderRow in shopDB.Orders) { orderRow["NameEmployee"] = orderRow.EmployeesRow.FName; orderRow["SurnameEmployee"] = orderRow.EmployeesRow.LName; orderRow["SurnameCustomer"] = orderRow.CustomersRow.FName; orderRow["NameCustomer"] = orderRow.CustomersRow.LName; } dataGridView1.DataSource = shopDB.Orders; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Visible = false; dataGridView1.Columns[3].Visible = false; dataGridView1.Columns["OrderDate"].Visible = false; }
protected override void Dispose(bool disposing) { if (disposing) { ShopDB db = new ShopDB(); db.Dispose(); } base.Dispose(disposing); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ShopDB db = new ShopDB(); db.Database.Initialize(true); db.Database.CreateIfNotExists(); }
private void Form1_Load(object sender, EventArgs e) { ShopDB shopDB = new ShopDB(); var customersTableAdapter = new ShopDBTableAdapters.CustomersTableAdapter(); ShopDB.CustomersDataTable customers = customersTableAdapter.GetData(); dataGridView1.DataSource = customers; var employeesTableAdapter = new ShopDBTableAdapters.EmployeesTableAdapter(); ShopDB.EmployeesDataTable employees = employeesTableAdapter.GetData(); dataGridView2.DataSource = employees; }
private void Window_Loaded(object sender, RoutedEventArgs e) { ShopDB dataBase = new ShopDB(); var empAdapter = new ShopDBTableAdapters.EmployeesTableAdapter(); var employees = empAdapter.GetData(); var ordAdapter = new ShopDBTableAdapters.OrdersTableAdapter(); var orders = ordAdapter.GetData(); var ordDetAdapter = new ShopDBTableAdapters.OrderDetailsTableAdapter(); var orderDet = ordDetAdapter.GetData(); employees.Columns.Add("TotalSum", typeof(decimal)); var sum = from em in employees.AsQueryable() join ord in orders.AsQueryable() on em.EmployeeID equals ord.EmployeeID into ordGroup from o in ordGroup join det in orderDet.AsQueryable() on o.OrderID equals det.OrderID into detGroup select new { FName = em.FName, LName = em.LName, Total = detGroup.Sum(od => od.TotalPrice) }; var full = from s in sum.AsQueryable() group s by new { s.FName, s.LName } into g select new { FName = g.Key.FName, LName = g.Key.LName, Total = g.Sum(a => a.Total) }; dtgrd.ItemsSource = full; var custAdap = new ShopDBTableAdapters.CustomersTableAdapter(); DataTable customers = custAdap.GetData(); dtgrd2.ItemsSource = customers.Select("City = 'Киев'"); }
public static void SupplyerPannel(Supplyer user) { while (true) { Console.WriteLine("Select: \n 1. Set Car Price \n 2. Get a new car for the shop \n 0. Exit"); int id = 0; switch (Console.ReadLine()) { case "1": Console.Clear(); Console.WriteLine(ShopDB.GetCarsForSupplyer()); while (true) { Console.WriteLine("Select a car by ID to set a new price"); if (!int.TryParse(Console.ReadLine(), out id)) { Console.WriteLine("Invalid Selection"); continue; } Vehicle car = ShopDB.Vehicles.FirstOrDefault(x => x.Id == id); if (car == null) { Console.WriteLine("No car with that ID exists"); continue; } SetCarPrice(user, car); break; } continue; case "2": AquireNewCar(); continue; case "0": Helper.SlowPrint("Exiting menu..."); break; default: Console.WriteLine("Invalid input"); continue; } break; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { ShopDB dataBase = new ShopDB(); var empAdapter = new ShopDBTableAdapters.EmployeesTableAdapter(); var employees = empAdapter.GetData(); var ordAdapter = new ShopDBTableAdapters.OrdersTableAdapter(); var orders = ordAdapter.GetData(); var ordDetAdapter = new ShopDBTableAdapters.OrderDetailsTableAdapter(); var orderDet = ordDetAdapter.GetData(); employees.Columns.Add("TotalSum", typeof(decimal)); var sum = from em in employees.AsQueryable() join ord in orders.AsQueryable() on em.EmployeeID equals ord.EmployeeID into ordGroup from o in ordGroup join det in orderDet.AsQueryable() on o.OrderID equals det.OrderID into detGroup select new { FName = em.FName, LName = em.LName, Total = detGroup.Sum(od => od.TotalPrice) }; var full = from s in sum.AsQueryable() group s by new { s.FName, s.LName } into g select new { FName = g.Key.FName, LName = g.Key.LName, Total = g.Sum(a => a.Total) }; dtgrd.ItemsSource = full; var custAdap = new ShopDBTableAdapters.CustomersTableAdapter(); DataTable customers = custAdap.GetData(); dtgrd2.ItemsSource = customers.Select("City = 'Киев'"); }
static void Main(string[] args) { var shopDB = new ShopDB(); var customersRow = shopDB.Customers.NewCustomersRow(); customersRow.FName = "Aleksey"; customersRow.LName = "Petrov"; customersRow.MName = "Nikolaevich"; customersRow.Address1 = "Lujnaya"; customersRow.Address2 = null; //!!! not DBNull.Value customersRow.City = "Kiev"; customersRow.Phone = "(096)4578956"; customersRow.DateInSystem = new DateTime(2009, 09, 18); shopDB.Customers.Rows.Add(customersRow); shopDB.Customers.AddCustomersRow("Nikolay", "Aleksandrov", "Anatolevich", "Moskovskaya 15", null, "Chernigov", "(063)1298445", new DateTime(2010, 12, 30)); var selectedCustomer = shopDB.Customers.FindByCustomerNo(-2); selectedCustomer.BeginEdit(); //selectedCustomer.Phone = "testPhone"; selectedCustomer.SetMNameNull(); selectedCustomer.EndEdit(); //foreach (DataRow row in shopDB.Customers.Rows) //{ // foreach (DataColumn column in shopDB.Customers.Columns) // { // Console.WriteLine($"{column.ColumnName}: {row[column]}"); // } // Console.WriteLine(); //} Console.WriteLine($"Last name: {selectedCustomer.LName}"); Console.WriteLine($"First name: {selectedCustomer.FName}"); //Console.WriteLine($"Phone: {selectedCustomer.Phone}"); Console.WriteLine(selectedCustomer.IsMNameNull() ? "no middle name found" : $"Middle name: {selectedCustomer.MName}"); Console.ReadKey(); }
public ActionResult CreateProduct([Bind(Include = "ProductName, ProductPrice, ProductDescription, ProductImg, CategoryId")] Product product) { try { if (ModelState.IsValid) { order.AddProduct(product); } } catch (DataException dex) { ShopDB db = new ShopDB(); db.Logs.Add(new Log { LogDesc = dex.ToString() }); } return(RedirectToAction("Index")); }
protected override List <ButtonData> CreateMyButtonData() { var result = new List <ButtonData>();; foreach (var item in ResourceDB_mono.Instance._nowShopData._itemList) { var bttype = (ShopDB.GetBuyableCount(item) == 0) ? ButtonData.ButtonType.Unselectable : ButtonData.ButtonType.Selectable; var clickAction = new UnityEvent(); clickAction.AddListener(() => { UIController.Instance.SetFlashData("item", item); _MyUIBase.AddUI(_nextUI); }); var add = new ButtonData(item._data._displayName, clickAction, bttype); add._buttonImage = item._data._itemImage; add._additonalText = $"{item._data._price}G"; result.Add(add); } return(result); }
static void Main(string[] args) { ShopDB shopDB = new ShopDB(); // Для каждой таблицы типизированного DataSet создается адаптер, который позволяет заполнить эту таблицу данными var customersTableAdapter = new ShopDBTableAdapters.CustomersTableAdapter(); // Заполнение таблиц данными производится с помощью вызова метода Fill customersTableAdapter.Fill(shopDB.Customers); foreach (DataRow customersRow in shopDB.Customers.Rows) { foreach (DataColumn customersColumn in shopDB.Customers.Columns) { Console.WriteLine("{0}: {1}", customersColumn.ColumnName, customersRow[customersColumn]); } Console.WriteLine(); } }
static void Main(string[] args) { ShopDB shopDB = new ShopDB(); //ShopDB.CustomersRow customersRow = shopDB.Customers.NewCustomersRow(); shopDB.Customers.AddCustomersRow("Николай", "Александров", "Анатольевич", "Московская 15", null, "Чернигов", "(063)0215478", new DateTime(2008, 05, 15)); shopDB.Customers.AddCustomersRow("Константин", "Нимазов", "Алексеевич", "Октябрьская 5", null, "Киев", "(093)5487478", new DateTime(2009, 06, 20)); shopDB.Customers.AddCustomersRow("Андрей", "Макин", "Абрамович", "Сеновальная 7", null, "Витебск", "(098)7123478", new DateTime(2006, 12, 1)); // Использовани строго типизированного метода Find для нахождения строки по первичному ключу var selectedCustomer = shopDB.Customers.FindByCustomerNo(-3); selectedCustomer.BeginEdit(); selectedCustomer.Phone = "NewPhone"; selectedCustomer.EndEdit(); Console.WriteLine("Last name: " + selectedCustomer.LName); Console.WriteLine("First name: " + selectedCustomer.FName); Console.WriteLine("Phone: " + selectedCustomer.Phone); }
static void Main(string[] args) { var simpleShopDB = new DataSet(); simpleShopDB.ReadXmlSchema(@"C:\Users\HP\Desktop\Test\ShopDbSchema.xml"); simpleShopDB.ReadXml(@"C:\Users\HP\Desktop\Test\ShopDBData.xml"); var strongShopDB = new ShopDB(); strongShopDB.Customers.Merge(simpleShopDB.Tables["Customers"]); //merged customers table from simple data set with strongly typed data set shopdb foreach (DataRow row in strongShopDB.Customers.Rows) { foreach (DataColumn column in strongShopDB.Customers.Columns) { Console.WriteLine($"{column.ColumnName}: {row[column]}"); } Console.WriteLine(); } Console.ReadKey(); }
static void Main(string[] args) { DataSet simpleShopDb = new DataSet(); simpleShopDb.ReadXmlSchema(@"D:\ADO.NET\DATA\ShopDbSchema.xml"); simpleShopDb.ReadXml(@"D:\ADO.NET\DATA\ShopDBData.xml"); ShopDB strongedShopDB = new ShopDB(); strongedShopDB.Customers.Merge(simpleShopDb.Tables["Customers"]); strongedShopDB.Orders.Merge(simpleShopDb.Tables["Orders"]); var selectedCustomer = strongedShopDB.Customers.FindByCustomerNo(1); Console.WriteLine("{0} {1} {2}", selectedCustomer.LName, selectedCustomer.FName, selectedCustomer.MName + "\n"); foreach (var ordersRow in selectedCustomer.GetOrdersRows()) { Console.WriteLine("\tOrderID: " + ordersRow.OrderID); Console.WriteLine("\tOrderdate: " + ordersRow.OrderDate); Console.WriteLine(); } }
static void Main(string[] args) { DataSet simpleShopDb = new DataSet(); simpleShopDb.ReadXmlSchema(@"D:\ADO.NET\DATA\ShopDbSchema.xml"); simpleShopDb.ReadXml(@"D:\ADO.NET\DATA\ShopDBData.xml"); ShopDB strongedShopDB = new ShopDB(); //Слияние обычно применяется для клиентских приложений с целью включения последних изменений из источника данных в существующий класс DataTable. Это позволяет клиентскому приложению иметь класс DataTable, обновленный последними данными из источника. strongedShopDB.Customers.Merge(simpleShopDb.Tables["Customers"]); foreach (DataRow row in strongedShopDB.Customers.Rows) { foreach (DataColumn column in strongedShopDB.Customers.Columns) { Console.WriteLine("{0}: {1}", column.ColumnName, row[column]); } Console.WriteLine(); } }
static void Main(string[] args) { ShopDB shopDB = new ShopDB(); new CustomersTableAdapter(). Fill(shopDB.Customers); new OrdersTableAdapter(). Fill(shopDB.Orders); new OrderDetailsTableAdapter(). Fill(shopDB.OrderDetails); new ProductsTableAdapter(). Fill(shopDB.Products); foreach (var customer in shopDB.Customers) { var orders = customer.GetOrdersRows(); if (orders.Length > 0) { Console.WriteLine("{0} {1} {2}", customer.LName, customer.FName, customer.MName); Console.WriteLine(); foreach (var order in orders) { Console.WriteLine("\tOrderId:{0}, {1}", order.OrderID, order.OrderDate); foreach (var orderDetail in order.GetOrderDetailsRows()) { var product = orderDetail.ProductsRow; Console.WriteLine("\t\tLineItem:{0} - {1}, {2:C}", orderDetail.LineItem, product.Description.Trim(), orderDetail.TotalPrice); } Console.WriteLine(); } } } }
public static void ManagerPannel(Manager user) { while (true) { Console.WriteLine("Select: \n 1. Vehicle List \n 2. Store Managment \n 0. Exit"); switch (Console.ReadLine()) { case "1": Console.WriteLine(ShopDB.ShowAllVehicles()); continue; case "2": Console.WriteLine(ShopDB.ShowAllEmployees()); while (true) { Console.WriteLine("Pick an action"); Console.WriteLine("1. Fire an employee"); Console.WriteLine("2. Edit Salary"); switch (Console.ReadLine()) { case "1": while (true) { int id = 0; Console.WriteLine("Who would you like fired?"); if (int.TryParse(Console.ReadLine(), out id)) { User selected = ShopDB.Users.FirstOrDefault(x => x.Id == id); if (selected == null) { Console.WriteLine("There are not employees with that ID"); break; } else if (selected.Type == UserType.Manager) { Console.WriteLine("You cant fire Managers only the owner can edit them (in the code)"); break; } ShopDB.Users.Remove(selected); break; } break; } continue; case "2": while (true) { int id = 0; Console.WriteLine("Who would you like to edit?"); if (int.TryParse(Console.ReadLine(), out id)) { User selected = ShopDB.Users.FirstOrDefault(x => x.Id == id); if (selected == null) { Console.WriteLine("There are not employees with that ID"); break; } else if (selected.Type == UserType.Manager) { Console.WriteLine("You cant edit Managers only the owner can edit them (in the code)"); break; } UserUI.EditEmployeesSalary(user, (Supplyer)selected); break; } break; } continue; case "0": Helper.SlowPrint("Exiting menu"); break; default: Console.WriteLine("Invalid input"); continue; } break; } continue; case "0": Helper.SlowPrint("Exiting"); break; default: Console.WriteLine("Wrong Input"); continue; } break; } }
public static void GuestPannel() { Console.WriteLine(ShopDB.ShowForGuest()); }
public static void CostumerPannel(Costumer user) { int selected = 0; while (true) { Console.WriteLine($"{user.GetInfo()}"); Console.WriteLine("Select: \n 1. Buy \n 2. Browse \n 3. Add Funds \n 9. Change Password \n 0. Log Out"); switch (Console.ReadLine()) { case "1": Console.Clear(); ShopDB.ShowCarsForBuyer(); Console.WriteLine("Select A car to Buy"); if (!int.TryParse(Console.ReadLine(), out selected) || selected > ShopDB.Vehicles.Count) { Console.WriteLine("Car does not exist"); continue; } if (selected == 0) { Console.WriteLine("Come Back again"); continue; } BuyCar(user, ShopDB.Vehicles[selected - 1]); continue; case "2": Console.WriteLine(ShopDB.ShowAllVehicles()); Console.ReadKey(); Console.Clear(); continue; case "3": Helper.AddFunds(user); continue; case "9": Console.WriteLine("ChangePassword"); Console.WriteLine("Enter old password"); if (user.CheckPassword(Console.ReadLine())) { Console.WriteLine("Enter new password"); string password = Helper.PasswordValidation(); user.ChangePassword(password); Console.WriteLine("Password Succesfully changed"); } else { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Incorrect Password"); Console.ForegroundColor = ConsoleColor.White; } continue; case "0": Helper.SlowPrint("Loging out..."); break; default: Console.WriteLine("Wrong Input"); continue; } break; } }
public MenuService() { db = new ShopDB(); }