private void UpdateProductEventHandler(object sender) { try { txtCode.Text = sender.ToString(); var product = Product_Data.getProduct(sender.ToString()); txtNameProduct.Text = product.name; txtMark.Text = product.mark; txtPrice.Text = product.price.ToString(); this.in_stock = product.quantity; txtQuantity.Enabled = true; btnSum.Enabled = true; btnMinus.Enabled = true; txtQuantity.Text = count.ToString(); foreach (var item in Controls.OfType <Button>()) { if (!item.Enabled) { item.Enabled = true; } } } catch (Exception) { MessageBox.Show("There was a problem looking for the product, try with Products action.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
[Test] // #9 public void i() { //@ Remove a product and check if removed Product_Data dt = new Product_Data(); dt.Remove("4"); Assert.IsTrue(!dt.Contains("1")); }
[Test] // #5 public void e() { //@ Add a product and check if he existing Backend.Product dp = new Backend.Product("Soldiers", Backend.Product.Type.toys, "4", "12341234", true, 200, 200.0); Product_Data dt = new Product_Data(); dt.Add(dp); Assert.IsTrue(dt.Contains(dp.inventoryID)); }
[Test] // #3 public void c() { //@ Add a product and check if it existing Backend.Product dp = new Backend.Product("pentium", Backend.Product.Type.electronics, "1", "123123", true, 200, 200.0); Product_Data dt = new Product_Data(); dt.Add(dp); Assert.IsTrue(dt.Contains(dp.inventoryID)); }
public IHttpActionResult DeleteProductData(int ID) { string Token = HttpContext.Current.Request.Form["Token"]; //Find Data Product_Data data = db.Product_Data.SingleOrDefault(x => x.Product.Provider.Token == Token && x.ID == ID); if (data == null) { return(Ok(new { key = false, Message = "هذه البيانات غير موجودة" })); } //Delete Data From DB db.Product_Data.Remove(data); db.SaveChanges(); return(Ok(new { key = true, Message = "تم مسح العنصر بنجاح" })); }
public Main() { InitializeComponent(); EmartDataContext emartDataContext = new EmartDataContext(); //data classes of the enities List <DAL.User> userSqlDB = (from s in emartDataContext.Users select s).ToList(); List <Backend.User> userDB = Change.UserDalToBackendList(userSqlDB); User_Data user_data = new User_Data(userDB); List <DAL.Customer> clubMemberSqlDB = (from s in emartDataContext.Customers select s).ToList(); List <Club_Member> clubMemberDB = Change.CustomerDalToBackendList(clubMemberSqlDB); ClubMember_Data clubMember_data = new ClubMember_Data(clubMemberDB); List <DAL.Department> departmentSqlDB = (from s in emartDataContext.Departments select s).ToList(); List <Backend.Department> departmentDB = Change.DepartmentDalToBackendList(departmentSqlDB); Department_Data department_data = new Department_Data(departmentDB); List <DAL.Employee> EmployeeSqlDB = (from s in emartDataContext.Employees select s).ToList(); List <Backend.Employee> EmployeeDB = Change.EmployeeDalToBackendList(EmployeeSqlDB); Employee_Data employee_data = new Employee_Data(EmployeeDB); List <DAL.Product> productSqlDB = (from s in emartDataContext.Products select s).ToList(); List <Backend.Product> productDB = Change.ProductDalToBackendList(productSqlDB); Product_Data product_data = new Product_Data(productDB); List <DAL.Transaction> transactionSqlDB = (from s in emartDataContext.Transactions select s).ToList(); List <Backend.Transaction> transactionDB = Change.TransactionDalToBackendList(transactionSqlDB); List <DAL.Recipt> reciptSqlDB = (from s in emartDataContext.Recipts select s).ToList(); List <Backend.Receipt> reciptDB = Change.ReciptDalToBackendList(reciptSqlDB); Transaction_Data transaction_data = new Transaction_Data(transactionDB, reciptDB); Location_Data location_data = new Location_Data(); // managers DAL_Manager dal_manager = new DAL_Manager(user_data, clubMember_data, department_data, employee_data, product_data, transaction_data, location_data); BL_Manager BL_manager = new BL_Manager(dal_manager); Window mw = new MainWindow(BL_manager); mw.Show(); this.Close(); }
public override void Save() { try { var id = "PRT" + Security.Security.generateIdNumber(); var name = txtName.Text; var mark = txtBrand.Text; var price = double.Parse(txtPrice.Text); var quantity = int.Parse(txtQuantity.Text); Product_Data.updateProduct(new Product(id, name, mark, price, quantity)); MessageBox.Show("New Product added", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception) { MessageBox.Show("There were an error trying to add the product", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Delete() { if (rowindex == -1) { MessageBox.Show("Please Select Something"); } else { int b = TheDatabase.GetCommandDB()[rowindex].IdComanda; TheDatabase.Delete_FromTable(b); Command_Data.RemoveAt(rowindex); int k = Product_Data.Count; for (int i = 0; i < k; i++) { Product_Data.RemoveAt(0); } } }
public void Delete_All() { if (MessageBox.Show("Delete all commands?", "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { } else { TheDatabase.Delete_All_From_User(); int k = Command_Data.Count; for (int i = 0; i < k; i++) { Command_Data.RemoveAt(0); } int p = Product_Data.Count; for (int i = 0; i < p; i++) { Product_Data.RemoveAt(0); } } }
private void ItemQuery_Load(object sender, EventArgs e) { try { foreach (var item in Product_Data.getAllProducts()) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvProducts); row.Cells[0].Value = item.id; row.Cells[1].Value = item.name; row.Cells[2].Value = item.mark; row.Cells[3].Value = item.price; row.Cells[4].Value = item.quantity; dgvProducts.Rows.Add(row); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public IHttpActionResult AddProductData(int Product_ID) { string Token = HttpContext.Current.Request.Form["Token"]; string Key = HttpContext.Current.Request.Form["Key"]; string Value = HttpContext.Current.Request.Form["Value"]; //Find Product Product product = db.Products.SingleOrDefault(x => x.ID == Product_ID && x.Provider.Token == Token); if (product == null) { return(Ok(new { key = false, Message = "هذا المنتج غير موجود" })); } //Add Data To DB Product_Data data = new Product_Data { Item = Key, Value = Value, Product_ID = product.ID }; db.Product_Data.Add(data); db.SaveChanges(); return(Ok(new { key = true, Message = "تم اضافة العنصر بنجاح" })); }
public Product_BL(Product_Data dl) { itsDAL = dl; }