/// <summary>
        /// William Flood
        /// Created:
        /// 2017/03/29
        ///
        /// Adds a new supplier inventory to the database.
        /// </summary>
        ///
        /// <remarks>
        /// Aaron Usher
        /// Updated:
        /// 2017/04/21
        ///
        /// Standardized method.
        /// </remarks>
        ///
        /// <param name="supplierInventory">The supplier inventory to add</param>
        /// <returns>Rows affected.</returns>
        public static int CreateSupplierInventory(SupplierInventory supplierInventory)
        {
            var rows = 0;

            var conn    = DBConnection.GetConnection();
            var cmdText = @"sp_create_supplier_inventory";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@AGREEMENT_ID", supplierInventory.AgreementID);
            cmd.Parameters.AddWithValue("@DATE_ADDED", supplierInventory.DateAdded);
            cmd.Parameters.AddWithValue("@QUANTITY", supplierInventory.Quantity);

            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(rows);
        }
        List <SupplierInventory> GetSupplierInventory()
        {
            List <SupplierInventory> supplierInventories = new List <SupplierInventory>();
            List <Inventory>         inventory           = (List <Inventory>) Controller <RosePurchaseManagementEntities, Inventory> .GetEntitiesWithIncluded("BoxInventories", "Farm");

            List <Box> box = (List <Box>) Controller <RosePurchaseManagementEntities, Box> .GetEntitiesWithIncluded("BoxInventories");

            foreach (Inventory inventories in inventory)
            {
                foreach (BoxInventory boxes in inventories.BoxInventories)
                {
                    SupplierInventory supplierInventory = new SupplierInventory()
                    {
                        InventoryID = inventories.InventoryID,
                        FarmID      = inventories.FarmID,
                        FarmName    = inventories.Farm.FarmName,
                        Price       = inventories.Price_per_stem,
                        Quantity    = boxes.Quantity,
                    };
                    using (RosePurchaseManagementEntities context = new RosePurchaseManagementEntities())
                    {
                        var roseName = context.RoseSizes.Include("Rose").Where(x => x.RoseSizeID == inventories.RoseSizeID).Select(r => r.Rose.RoseName).FirstOrDefault();
                        supplierInventory.RoseName = roseName;
                    }
                    supplierInventories.Add(supplierInventory);
                }
            }
            return(supplierInventories);
        }
示例#3
0
 public void NewPurchaseOrderDetail(string orderid, string supid, List <ItemWithQtyModel> ItemList)
 {
     try
     {
         for (int i = 0; i < ItemList.Count; i++)
         {
             OrderListDetail old = new OrderListDetail();
             if (ItemList[i].Qty != 0)
             {
                 string id  = ItemList[i].Item_ID;
                 int    qty = ItemList[i].Qty;
                 old.Order_ID   = orderid;
                 old.Item_ID    = id;
                 old.Needed_Qty = qty;
                 var q = from x in context.SupplierInventories where x.Item_ID == id && x.Supplier_ID == supid select x;
                 SupplierInventory si = q.First();
                 si.Inventory_Qty = si.Inventory_Qty - old.Needed_Qty;
                 context.OrderListDetails.Add(old);
                 context.SaveChanges();
             }
         }
     }
     catch (Exception e)
     {
         e.Source = "Create purchase order detail fail!";
     }
 }
示例#4
0
 public bool CancelPurchaseOrder(string orderID, string remark)
 {
     try
     {
         var       q  = from x in context.OrderLists where x.Order_ID == orderID select x;
         OrderList ol = q.First();
         var       p  = from x in context.OrderListDetails where x.Order_ID == orderID select x;
         foreach (OrderListDetail od in p.ToList())
         {
             var r = from x in context.SupplierInventories where x.Item_ID == od.Item_ID && x.Supplier_ID == ol.Supplier_ID select x;
             SupplierInventory si = r.First();
             si.Inventory_Qty = si.Inventory_Qty + od.Needed_Qty;
         }
         ol.Status      = "Cancelled";
         ol.Finish_Date = DateTime.Now;
         if (remark != "")
         {
             ol.Remark = remark;
         }
         else
         {
             ol.Remark = "Cancelled";
         }
         context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
示例#5
0
        //CRUD supplier for specific stock item
        private void AddButton_Click(object sender, EventArgs e)
        {
            SupplierInventory si = getSupplierInventoryItem();
            int id = ctr.addSupplierInventory(si);

            MessageBox.Show("Add success!\n Your user ID is " + id.ToString(),
                            "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            reset();
        }
 /// <summary>
 /// Created 2017-03-29 by William Flood
 /// </summary>
 /// <param name="toAdd"></param>
 /// <returns></returns>
 public int CreateSupplierInventory(SupplierInventory toAdd)
 {
     try
     {
         return(SupplierInventoryAccessor.CreateSupplierInventory(toAdd));
     } catch
     {
         throw;
     }
 }
示例#7
0
        /// <summary>
        /// William Flood
        /// Created: 2017/03/30
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPost_Click(object sender, RoutedEventArgs e)
        {
            int?agreementId = null;
            int?quantity    = null;
            int parsedQuantity;

            if (Int32.TryParse(txtQuantity.Text, out parsedQuantity))
            {
                quantity = parsedQuantity;
            }
            else
            {
                MessageBox.Show("Quantity needs an integer");
                return;
            }
            if (cboAgreement.SelectedIndex >= 0)
            {
                agreementId = _agreementList[cboAgreement.SelectedIndex].AgreementId;
            }
            else
            {
                MessageBox.Show("Select an agreement");
                return;
            }
            if (null == dpDateAdded.SelectedDate)
            {
                MessageBox.Show("Select a date");
                return;
            }
            try
            {
                var toAdd = new SupplierInventory()
                {
                    AgreementID = agreementId,
                    DateAdded   = dpDateAdded.SelectedDate,
                    Quantity    = quantity
                };
                _supplyInventorymanager.CreateSupplierInventory(toAdd);
                MessageBox.Show("Inventory saved");
                this.Close();
            } catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        public void AddSupplierInventory(SupplierInventoryDto value)
        {
            var supplierInventory = new SupplierInventory
            {
                Id = value.ID,
                SupplierStandardInventoryId = value.SupplierStandardInventoryId,
                Qty           = value.Qty,
                UnitPrice     = value.UnitPrice,
                AvailableQty  = value.AvailableQty,
                ProcessingQty = value.ProcessingQty,
                InventoryDate = DateTime.Now
            };

            this.supplierInventoryDataService.AddSupplierInventory(supplierInventory);
        }
        public static void UpdateSupplierInventory(SupplierInventory inventory, string buyerLinkedSku)
        {
            var requestUrl = $"buyerinventoryservice/rest/linkitem/{Key}";
            var request    = new RestRequest(requestUrl, Method.POST);
            var body       = new
            {
                BuyerSKU    = buyerLinkedSku,
                SupplierId  = inventory.SupplierId.Value,
                SupplierSKU = inventory.SupplierSku
            };

            request.AddJsonBody(body);
            var response = Client.Execute <ApiResult <BuyerInventoryLinkItemResult> >(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception("Error linking the buyer inventory item");
            }
        }
示例#10
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            SupplierInventory si = getSupplierInventoryItem();

            try
            {
                si.ID = int.Parse(textBoxID.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Input supplier ID first.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            ctr.updateSupplierInventory(si);
            MessageBox.Show("Update success!\n ",
                            "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            reset();
        }
示例#11
0
        private SupplierInventory getSupplierInventoryItem()
        {
            int supID = 0;

            try
            {
                supID = int.Parse(SupplierTextBox.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Input supplier ID first.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            SupplierInventory si = new SupplierInventory();

            si.ItemID     = stockID;
            si.SupplierID = supID;
            return(si);
        }
示例#12
0
 internal void updateSupplierInventory(SupplierInventory si)
 {
     siDAL.updateItem(si);
 }
示例#13
0
 internal int addSupplierInventory(SupplierInventory si)
 {
     return(siDAL.addItem(si));
 }
 public void UpdateSupplierInventory(SupplierInventory supplierInventory)
 {
     databaseContext.SupplierInventory.Update(supplierInventory);
     databaseContext.SaveChanges();
 }
 public void AddSupplierInventory(SupplierInventory supplierInventory)
 {
     databaseContext.SupplierInventory.Add(supplierInventory);
     databaseContext.SaveChanges();
 }