/// <summary> /// Adds a new purchase /// </summary> /// <param name="purchase"></param> public void AddPurchase(Purchase purchase) { if (purchase.SupplierId == null) { throw new ArgumentNullException(nameof(purchase.SupplierId), "Purchase SupplierId is null"); } using (var scope = new TransactionScope()) { using (var connection = Connector.GetConnection()) { var purchaseDal = new PurchaseDal(connection); var itemDal = new ItemDal(connection); purchaseDal.Insert(purchase.SupplierId.Value, purchase.Amount, purchase.Note, purchase.IsSettled); purchase.Id = purchaseDal.GetLastInsertId(); if (purchase.Id == null) { throw new ArgumentNullException(nameof(purchase.Id), "Purchase Id null after insert"); } var purchaseItemDal = new PurchaseItemDal(connection); // Insert purchase items purchaseItemDal.InsertMultiple(purchase.Id.Value, purchase.PurchaseItems); // Update inventory foreach (var purchaseItem in purchase.PurchaseItems) { itemDal.Update(purchaseItem.ItemId, stockIncrement: (int)purchaseItem.Qty); } } scope.Complete(); } }
protected void btnSaveProduct_Click(object sender, EventArgs e) { RequestData data = new RequestData(); hdReqIdStock.Value = data.RequestID_Stock; Item item = null; foreach (ListItem chb in chbProdect.Items) { item = new Item(); string reqId = hdReqIdStock.Value; if (chb.Selected == true) { item.Code = chb.Value; item.Name = chb.Text; //insert to table request_stock ItemDal dal = new ItemDal(); dal.RequestStockInsert(item, reqId); lblStatus.Text = "บันทึกสินค้า เรียบร้อย"; lblStatus.ForeColor = System.Drawing.Color.Red; } } }//btnSaveProduct_Click
public ReviewService(ReviewDal reviewDal, ItemDal itemDal, UserDal userDal, IMapper mapper) { _reviewDal = reviewDal; _itemDal = itemDal; _userDal = userDal; _mapper = mapper; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request["ReqId"] != null) { if (Request["ReqId"] != "") { string req_id = Request["ReqId"].ToString(); ItemDal dal = new ItemDal(); DataSet ds = dal.GetRequestStockById(req_id); if (ds != null && ds.Tables[0].Rows.Count > 0) { lbReqId.Text = req_id; ResultGridView.DataSource = ds.Tables[0]; ResultGridView.DataBind(); } } } } else { } }
public ShopService(IIdentity identity) { heroDal = new HeroDal(); itemDal = new ItemDal(); eqService = new EquipmentService(); equipmentDal = new EquipmentDal(); heroService = new HeroService(identity); myHero = heroDal.Get(new Hero { Id = int.Parse(identity.Name) }).GetObject(); }
public List <Item> GetItem(Int16 ID) { try { ItemDal objdal = new ItemDal(); return(objdal.Read(ID)); } catch { throw; } }
/// <summary> /// Returns items matching given search parameters /// and optionally, the itemType /// </summary> /// <param name="productId"></param> /// <param name="name"></param> /// <param name="productType"></param> /// <returns></returns> public IEnumerable <Item> GetItems(uint?productId = null, string name = null, ProductType?productType = null) { if (productType == ProductType.Service) { throw new NotSupportedException("ProductType 'Service' is not applicable here"); } using (var connection = Connector.GetConnection()) { var itemDal = new ItemDal(connection); return(itemDal.Search(productId, name == null ? null : $"%{name}%", productType)); } }
}//btnSend_Click private void GetListItem() { ItemDal dal = new ItemDal(); DataSet ds = dal.GetListItem(); if (ds != null && ds.Tables[0].Rows.Count > 0) { chbProdect.DataValueField = "Code"; chbProdect.DataTextField = "Name"; chbProdect.DataSource = ds.Tables[0]; chbProdect.DataBind(); } }
public List <Item> GetItems() { try { ItemDal objdal = new ItemDal(); return(objdal.GetItems()); } catch { throw; } }
/// <summary> /// Add any new product. Automatically determines the type of item and insert accordingly. /// </summary> /// <param name="product"></param> public void AddProduct(Product product) { using (var scope = new TransactionScope()) { using (var connection = Connector.GetConnection()) { var productDal = new ProductDal(connection); productDal.Insert(product is Item ? ((Item)product).Model : product.Name, product.ProductType); var id = productDal.GetLastInsertId(); product.Id = id; if (product.Id == null) { throw new ArgumentNullException(nameof(product.Id), "Product Id is null"); } if (product is Item) { var item = (Item)product; var itemDal = new ItemDal(connection); itemDal.Insert(id, item.StockQty, item.UnitPrice); if (item is Alloywheel) { var alloywheel = (Alloywheel)item; var alloywheelDal = new AlloywheelDal(connection); alloywheelDal.Insert(id, alloywheel.Brand, alloywheel.Dimension); } if (item is Tyre) { var tyre = (Tyre)item; var tyreDal = new TyreDal(connection); tyreDal.Insert(id, tyre.Brand, tyre.Dimension, tyre.Country); } if (item is Battery) { var battery = (Battery)item; var batteryDal = new BatteryDal(connection); batteryDal.Insert(id, battery.Brand, battery.Capacity, battery.Voltage); } } } scope.Complete(); } }
/// <summary> /// Adds a new Order /// </summary> public void AddOrder(Order order) { // Exception handling if (order.OrderItems == null) { throw new ArgumentNullException(nameof(order.OrderItems), "Attempted inserting order without orderEntries initialized"); } if (order.IsCancelled) { throw new ArgumentException("Attempted inserting a cancelled order", nameof(order.IsCancelled)); } using (var scope = new TransactionScope()) { using (var connection = Connector.GetConnection()) { var orderDal = new OrderDal(connection); var orderItemDal = new OrderItemDal(connection); var itemDal = new ItemDal(connection); // Insert order record orderDal.Insert(order.CustomerId, order.Amount, order.Note); order.Id = orderDal.GetLastInsertId(); if (order.Id == null) { throw new ArgumentNullException(nameof(order.Id), "Order has not been set after insert"); } // Insert order entries orderItemDal.InsertMultiple(order.Id.Value, order.OrderItems); // Update inventory foreach (var orderItem in order.OrderItems) { itemDal.Update(orderItem.ProductId, stockIncrement: (int)-orderItem.Qty); } } scope.Complete(); } }
}//btnSaveProduct_Click protected void btnLoadDataService_Click(object sender, EventArgs e) { WebService1 obj = new WebService1(); string dataJson = obj.GetItemAll(); //return json string xml = obj.GetItemByCode("ITEM_003"); //retuen xml if (xml != "") { StringReader txtReader = new StringReader(xml); XmlSerializer xmlSerializer = new XmlSerializer(typeof(Item)); Item data = (Item)xmlSerializer.Deserialize(txtReader); } if (dataJson != "") { List <Item> item_data = JsonConvert.DeserializeObject <List <Item> >(dataJson); if (item_data != null && item_data.Count > 0) { foreach (Item item in item_data) { ItemDal dal = new ItemDal(); dal.StockInsert(item); this.Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "myscript", "Message_Show('Upload Success')", true); GetListItem(); btnLoadDataService.Enabled = false; } } } }
public ItemLogic() { this.dal = new ItemDal(); }
public ItemService(ItemDal itemDal, CategoryDal categoryDal, IMapper mapper) { _itemDal = itemDal; _categoryDal = categoryDal; _mapper = mapper; }
public ItemService() { itemDal = new ItemDal(); }
public void ChooseActionForItems() { ItemDal itemDal = new ItemDal(); Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); Console.WriteLine("What action you want to choose?\n" + "1. View all items\n" + "2. Get item by Id\n" + "3. Get item by name of column\n" + "4. Add item\n" + "5. Edit info about item\n" + "6. Delete item by Id\n" + "7. Delete item by name of column\n" + "8. Back to start menu"); Console.Write("\nYour selection: "); string ch = Console.ReadLine(); switch (ch) { case "1": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); itemDal.PrintListOfItems(itemDal.GetAll()); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "2": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\nId: "); int id = Convert.ToInt32(Console.ReadLine()); itemDal.PrintItem(itemDal.GetById(id)); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "3": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\nName of column: "); string fieldName = Console.ReadLine(); Console.WriteLine("\nValue: "); string text = Console.ReadLine(); itemDal.PrintListOfItems(itemDal.GetByFieldName(fieldName, text)); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "4": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); Console.WriteLine("NAME: "); string name = Console.ReadLine(); Console.WriteLine("DESCRIPTION: "); string desc = Console.ReadLine(); Console.WriteLine("CATEGORY_ID: "); int categId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("PRICE: "); decimal price = Convert.ToDecimal(Console.ReadLine()); Console.WriteLine("IN_STOCK: "); string inStock = Console.ReadLine(); Item item = new Item(name, desc, categId, price, inStock); itemDal.Insert(item); Console.WriteLine("Item succesfully inserted :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "5": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); Console.WriteLine("Name of column (set): "); string fieldName = Console.ReadLine(); Console.WriteLine("Value (set): "); string text = Console.ReadLine(); Console.WriteLine("Name of column (condition): "); string fieldCondition = Console.ReadLine(); Console.WriteLine("Value (condition): "); string textCondition = Console.ReadLine(); itemDal.UpdateByFieldName(fieldName, text, fieldCondition, textCondition); Console.WriteLine("Item succesfully updated :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "6": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\nId: "); int id = Convert.ToInt32(Console.ReadLine()); itemDal.DeleteById(id); Console.WriteLine("Item succesfully deleted :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "7": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n "); Console.WriteLine("Name of column (condition): "); string fieldCondition = Console.ReadLine(); Console.WriteLine("Value (condition): "); string textCondition = Console.ReadLine(); itemDal.DeleteByFieldName(fieldCondition, textCondition); Console.WriteLine("Item succesfully deleted :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "8": { Menu menu = new Menu(); menu.ChooseTable(); break; } default: Console.WriteLine("Invalid selection. Please select 1, 2, 3, 4, 5, 6, 7 or 8."); break; } }
public ItemBll(RestClient restClient) { _itemDal = new ItemDal(restClient); }