コード例 #1
0
        public void UpdatePriority(string id)
        {
            ItemSupplier itemSupplier = itemSupplierContext.Get(id);

            itemSupplier.Priority += 1;
            itemSupplierContext.Commit();
        }
        /// <summary>
        /// Eric Bostwick
        /// Created 2/4/2019
        /// Inserts records to the itemsupplier table
        /// </summary>
        /// <returns>
        /// 1 if successful 0 if not
        /// </returns>
        ///
        public int InsertItemSupplier(ItemSupplier itemSupplier)
        {
            int result;
            var conn    = DBConnection.GetDbConnection();
            var cmdText = @"sp_create_itemsupplier";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@ItemID", itemSupplier.ItemID);
            cmd.Parameters.AddWithValue("@SupplierID", itemSupplier.SupplierID);
            cmd.Parameters.AddWithValue("@PrimarySupplier", itemSupplier.PrimarySupplier);
            cmd.Parameters.AddWithValue("@LeadTimeDays", itemSupplier.LeadTimeDays);
            cmd.Parameters.AddWithValue("@UnitPrice", itemSupplier.UnitPrice);
            cmd.Parameters.AddWithValue("@SupplierItemID", itemSupplier.ItemSupplierID);

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

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Eric Bostwick
        /// Created: 2/7/19
        /// Copies an itemsupplier object to a new itemsupplier object
        /// </summary>
        /// <param name="item">
        /// The itemsupplier to be copied
        /// </param>
        /// <returns>
        /// A copy of the itemsupplier object
        /// </returns>
        private static ItemSupplier CopyItemSupplier(ItemSupplier itemSupplier)
        {
            ItemSupplier _newItemSupplier = new ItemSupplier()
            {
                Address            = itemSupplier.Address,
                City               = itemSupplier.City,
                ContactFirstName   = itemSupplier.ContactFirstName,
                ContactLastName    = itemSupplier.ContactLastName,
                Country            = itemSupplier.Country,
                DateAdded          = itemSupplier.DateAdded,
                Description        = itemSupplier.Description,
                Email              = itemSupplier.Email,
                ItemID             = itemSupplier.ItemID,
                LeadTimeDays       = itemSupplier.LeadTimeDays,
                Name               = itemSupplier.Name,
                PhoneNumber        = itemSupplier.PhoneNumber,
                PostalCode         = itemSupplier.PostalCode,
                PrimarySupplier    = itemSupplier.PrimarySupplier,
                State              = itemSupplier.State,
                SupplierID         = itemSupplier.SupplierID,
                UnitPrice          = itemSupplier.UnitPrice,
                ItemSupplierActive = itemSupplier.ItemSupplierActive
            };

            return(_newItemSupplier);
        }
コード例 #4
0
        //overloading the updatePriority method
        public void UpdatePriority(string id, int order)
        {
            ItemSupplier itemSupplier = itemSupplierContext.Get(id);

            itemSupplier.Priority = order;
            itemSupplierContext.Commit();
        }
        public void TestCreateItemSupplierInValidInputUnitPriceGreaterThan9999()
        {
            //arrange
            ItemSupplier newItemSupplier = new ItemSupplier()
            {
                ItemID             = 100004,
                SupplierID         = 100009,
                Active             = true,
                Address            = "2455 Staggering Home St",
                City               = "North Liberty",
                State              = "IA",
                PostalCode         = "52446",
                Country            = "USA",
                ContactFirstName   = "Joe",
                ContactLastName    = "Smith",
                PhoneNumber        = "13193353333",
                DateAdded          = DateTime.Parse("2011-05-15"),
                Description        = "",
                Email              = "",
                ItemSupplierActive = true,
                Name               = "Alcohol Whole Supply",
                PrimarySupplier    = true,
                LeadTimeDays       = 10,
                UnitPrice          = 10000M
            };

            //Act
            _itemSupplierManager.CreateItemSupplier(newItemSupplier);
        }
コード例 #6
0
        internal static void CreatePO(List <ItemSupplier> listrr)
        {
            PurchaseOrder po = new PurchaseOrder();

            po.items = new List <ItemSupplier>();
            ItemSupplier xx  = new ItemSupplier();
            int          sId = listrr.FirstOrDefault().item.Id;
            int          iId = listrr.FirstOrDefault().supplier.Id;

            using (var db = new ADDbContext())
            {
                foreach (ItemSupplier its in listrr)
                {
                    if (db.ItemSupplier.Where(x => x.item.Id == its.item.Id && x.supplier.Id == its.supplier.Id).Any())
                    {
                        xx = db.ItemSupplier.Where(x => x.item.Id == its.item.Id && x.supplier.Id == its.supplier.Id).FirstOrDefault();
                    }

                    po.items.Add(xx);
                }


                po.RequestDelivDate = DateTime.Today.AddDays(15);
                po.status           = "pending";
                db.PurchaseOrder.Add(po);
                db.SaveChanges();
            }
        }
コード例 #7
0
        public void Save(ItemSupplier itemSupplier)
        {
            int count = GetSuppliersByItem(itemSupplier.ItemId).Count();
            int p     = 0;

            if (count == 0)
            {
                p = 3;
            }
            else if (count == 1)
            {
                p = 2;
            }
            else if (count == 2)
            {
                p = 1;
            }

            ItemSupplier iSup = new ItemSupplier()
            {
                ItemId     = itemSupplier.ItemId,
                Price      = itemSupplier.Price,
                SupplierId = itemSupplier.SupplierId,
                Priority   = p
            };

            itemSupplierContext.Add(iSup);
            itemSupplierContext.Commit();
        }
コード例 #8
0
        /// <summary>
        /// This method is used for insert new category in database. - JJ
        /// </summary>
        /// <param name="category">object of CategoryAC</param>
        /// <param name="companyId"></param>
        /// <returns>saved object of CategoryAC</returns>
        public CategoryAC SaveCategory(CategoryAC category, int companyId)
        {
            try
            {
                var categorys = new Category
                {
                    CompanyId        = companyId,
                    GroupParamTypeId = category.GroupParamTypeId,
                    BrandParamTypeId = category.BrandParamTypeId,
                    CreatedDateTime  = DateTime.UtcNow,
                };
                _categoryContext.Add(categorys);
                _categoryContext.SaveChanges();
                category.CategoryId = categorys.Id;

                var supplier = new ItemSupplier
                {
                    SupplierId      = category.SupplierId,
                    CategoryId      = category.CategoryId,
                    CreatedDateTime = DateTime.UtcNow
                };
                _itemSupplierContext.Add(supplier);
                _itemSupplierContext.SaveChanges();

                return(category);
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
コード例 #9
0
 /// <summary>
 /// This method is used for getting list of Item Suppliers. - JJ
 /// </summary>
 /// <param name="id">ID OF Category</param>
 /// <returns>list of object of ItemSupplier</returns>
 public List <ItemSupplier> GetItemSupplierList(int id)
 {
     try
     {
         var supplierList = new List <ItemSupplier>();
         var listSupplier = _itemSupplierContext.Fetch(x => x.CategoryId == id && x.IsDelete == false).ToList();
         foreach (var supplier in listSupplier)
         {
             ItemSupplier itemsupplier = new ItemSupplier
             {
                 CategoryId      = supplier.CategoryId,
                 SupplierId      = supplier.SupplierId,
                 SupplierProfile = supplier.SupplierProfile,
                 Id = supplier.Id,
                 CreatedDateTime = supplier.CreatedDateTime
             };
             supplierList.Add(itemsupplier);
         }
         return(supplierList);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #10
0
 //Contructor If we are adding an item supplier
 public frmAddItemSupplierForItem(Item item, EditMode editmode)
 {
     InitializeComponent();
     _item         = item;
     _itemSupplier = new ItemSupplier();
     _editMode     = editmode;
     LoadControls();
     LoadSupplierCombo();
 }
コード例 #11
0
        //Constructor if we are editing an item supplier
        public frmAddItemSupplierForItem(Item item, ItemSupplier itemSupplier, EditMode editMode)
        {
            InitializeComponent();
            _item         = item;
            _itemSupplier = itemSupplier;
            _editMode     = editMode;

            LoadControls();
        }
        public List <ItemSupplier> SelectItemSuppliersByItemID(int itemID)
        {
            /// <summary>
            /// Eric Bostwick
            /// Created 2/4/2019
            /// Gets list of itemsuppliers from itemsupplier table
            /// using the itemID
            /// </summary>
            /// <returns>
            /// List of ItemSupplier Objects
            /// </returns>
            {
                List <ItemSupplier> itemSuppliers = new List <ItemSupplier>();
                var conn    = DBConnection.GetDbConnection();
                var cmdText = @"sp_select_itemsuppliers_by_itemid";  //sp_retrieve_itemsuppliers_by_itemid
                var cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@ItemID", itemID);

                try
                {
                    conn.Open();
                    var reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            ItemSupplier itemSupplier = new ItemSupplier();

                            itemSupplier.ItemID             = reader.GetInt32(reader.GetOrdinal("ItemID"));
                            itemSupplier.SupplierID         = reader.GetInt32(reader.GetOrdinal("SupplierID"));
                            itemSupplier.PrimarySupplier    = reader.GetBoolean(reader.GetOrdinal("PrimarySupplier"));
                            itemSupplier.LeadTimeDays       = reader.GetInt32(reader.GetOrdinal("LeadTimeDays"));
                            itemSupplier.UnitPrice          = (decimal)reader.GetSqlMoney(reader.GetOrdinal("UnitPrice"));
                            itemSupplier.Name               = reader["Name"].ToString();
                            itemSupplier.Description        = reader["Description"].ToString();
                            itemSupplier.ItemSupplierActive = reader.GetBoolean(reader.GetOrdinal("ItemSupplierActive"));
                            itemSupplier.ItemSupplierID     = reader.GetInt32(reader.GetOrdinal("SupplierItemID"));
                            itemSuppliers.Add(itemSupplier);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    conn.Close();
                }

                return(itemSuppliers);
            }
        }
        public void TestUpdateItemSupplierInvalidLeadTimeDays366()
        {
            //Arrange
            ItemSupplier newItemSupplier = new ItemSupplier();

            setItemSupplier(newItemSupplier, _itemSuppliers[0]);
            newItemSupplier.LeadTimeDays = 366;
            //Act
            _itemSupplierManager.UpdateItemSupplier(newItemSupplier, _itemSuppliers[0]);
        }
        public void TestUpdateItemSupplierInvalidUnitPriceNegative()
        {
            //Arrange
            ItemSupplier newItemSupplier = new ItemSupplier();

            setItemSupplier(newItemSupplier, _itemSuppliers[0]);
            newItemSupplier.UnitPrice = -0.01M;
            //Act
            _itemSupplierManager.UpdateItemSupplier(newItemSupplier, _itemSuppliers[0]);
        }
        public void TestUpdateItemSupplierInvalidUnitPriceTooHigh()
        {
            //Arrange
            ItemSupplier newItemSupplier = new ItemSupplier();

            setItemSupplier(newItemSupplier, _itemSuppliers[0]);
            newItemSupplier.UnitPrice = 10000.00M;
            //Act
            _itemSupplierManager.UpdateItemSupplier(newItemSupplier, _itemSuppliers[0]);
        }
        /// <summary>
        /// Eric Bostwick
        /// Created 2/4/2019
        /// Gets an ItemSupplier from itemsupplier table
        /// using the itemID and supplierid
        /// </summary>
        /// <returns>
        /// ItemSupplier Object
        /// </returns>
        public ItemSupplier SelectItemSupplierByItemIDandSupplierID(int itemID, int supplierID)
        {
            ItemSupplier itemSupplier = new ItemSupplier();
            var          conn         = DBConnection.GetDbConnection();
            var          cmdText      = @"sp_select_itemsupplier_by_itemid_and_supplierid"; //sp_retrieve_itemsupplier_by_itemid_and_supplyid
            var          cmd          = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@ItemID", itemID);
            cmd.Parameters.AddWithValue("@SupplierID", supplierID);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        itemSupplier.ItemID             = reader.GetInt32(reader.GetOrdinal("ItemID"));
                        itemSupplier.SupplierID         = reader.GetInt32(reader.GetOrdinal("SupplierID"));
                        itemSupplier.PrimarySupplier    = reader.GetBoolean(reader.GetOrdinal("PrimarySupplier"));
                        itemSupplier.LeadTimeDays       = reader.GetInt32(reader.GetOrdinal("LeadTimeDays"));
                        itemSupplier.UnitPrice          = (decimal)reader.GetSqlMoney(reader.GetOrdinal("UnitPrice"));
                        itemSupplier.Address            = reader["Address"].ToString();
                        itemSupplier.City               = reader["City"].ToString();
                        itemSupplier.ContactFirstName   = reader["ContactFirstName"].ToString();
                        itemSupplier.ContactLastName    = reader["ContactLastName"].ToString();
                        itemSupplier.Country            = reader["Country"].ToString();
                        itemSupplier.DateAdded          = reader.GetDateTime(reader.GetOrdinal("DateAdded"));
                        itemSupplier.Description        = reader["Description"].ToString();
                        itemSupplier.Email              = reader["Email"].ToString();
                        itemSupplier.Name               = reader["Name"].ToString();
                        itemSupplier.Active             = reader.GetBoolean(reader.GetOrdinal("SupplierActive"));
                        itemSupplier.PhoneNumber        = reader["PhoneNumber"].ToString();
                        itemSupplier.PostalCode         = reader["PostalCode"].ToString();
                        itemSupplier.State              = reader["State"].ToString();
                        itemSupplier.ItemSupplierActive = reader.GetBoolean(reader.GetOrdinal("ItemSupplierActive"));
                        itemSupplier.ItemSupplierID     = reader.GetInt32(reader.GetOrdinal("SupplierItemID"));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }

            return(itemSupplier);
        }
        public ItemSupplier SelectItemSupplierByItemIDandSupplierID(int itemID, int supplierID)
        {
            ItemSupplier i = new ItemSupplier();

            i = _itemSuppliers.Find(x => x.ItemID == itemID & x.SupplierID == supplierID);
            if (i == null)
            {
                throw new ArgumentException("Item Supplier Not Found");
            }
            return(i);
        }
コード例 #18
0
 //Need to Load up the _itemSupplier Object to fill out the supplier data on the screen
 private void LoadItemSupplier()
 {
     try
     {
         _itemSupplier = _itemSupplierManager.RetrieveItemSupplier(_item.ItemID, _itemSupplier.SupplierID);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public void TestRetrieveItemSupplier()
        {
            //Arrange
            ItemSupplier _itemsupplier = null;

            //Act
            _itemsupplier = _itemSupplierManager.RetrieveItemSupplier(100002, 100005);
            //Assert
            Assert.AreEqual(_itemsupplier.ItemID, 100002);
            Assert.AreEqual(_itemsupplier.SupplierID, 100005);
        }
        public void TestDeleteItemSupplier()
        {
            //Arrange This is a known item supplier
            int          itemID       = 100002;
            int          supplierID   = 100005;
            ItemSupplier itemSupplier = new ItemSupplier();

            //Act
            _itemSupplierManager.DeleteItemSupplier(itemID, supplierID);
            //Assert should throw exception
            itemSupplier = _itemSupplierManager.RetrieveItemSupplier(itemID, supplierID);
        }
        public void TestUpdateItemSupplierValidUnit5000()
        {
            //Arrange
            ItemSupplier newItemSupplier = new ItemSupplier();

            setItemSupplier(newItemSupplier, _itemSuppliers[0]);
            newItemSupplier.UnitPrice = 5000.00M;
            //Act
            _itemSupplierManager.UpdateItemSupplier(newItemSupplier, _itemSuppliers[0]);
            //Assert
            Assert.AreEqual(_itemSupplierManager.RetrieveItemSupplier(_itemSuppliers[0].ItemID, _itemSuppliers[0].SupplierID).UnitPrice, 5000.00M);
        }
        public void TestUpdateItemSupplierLeadTimeDays365()
        {
            //Arrange
            ItemSupplier newItemSupplier = new ItemSupplier();

            setItemSupplier(newItemSupplier, _itemSuppliers[0]);
            newItemSupplier.LeadTimeDays = 365;
            //Act
            _itemSupplierManager.UpdateItemSupplier(newItemSupplier, _itemSuppliers[0]);
            //Assert
            Assert.AreEqual(_itemSupplierManager.RetrieveItemSupplier(_itemSuppliers[0].ItemID, _itemSuppliers[0].SupplierID).LeadTimeDays, 365);
        }
コード例 #23
0
 /// <summary>
 /// check itemSupplier exists in databse or not. - JJ
 /// </summary>
 /// <param name="itemSupplier">object of ItemSupplier</param>
 /// <returns>return true if itemSupplier already exist,otherwise false</returns>
 public bool CheckItemSupplierExixtsOrNot(ItemSupplier itemSupplier)
 {
     try
     {
         return(_itemSupplierContext.Fetch(x => x.SupplierId == itemSupplier.SupplierId && x.CategoryId == itemSupplier.CategoryId && x.Id != itemSupplier.Id && x.IsDelete == false).Any());
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
        public void TestUpdateItemSupplierMakeInActive()
        {
            //Arrange
            ItemSupplier newItemSupplier = new ItemSupplier();

            setItemSupplier(newItemSupplier, _itemSuppliers[0]);
            newItemSupplier.ItemSupplierActive = false;
            //Act
            _itemSupplierManager.UpdateItemSupplier(newItemSupplier, _itemSuppliers[0]);
            //Assert
            Assert.AreEqual(_itemSupplierManager.RetrieveItemSupplier(_itemSuppliers[0].ItemID, _itemSuppliers[0].SupplierID).ItemSupplierActive, false);
        }
        //[ExpectedException(typeof(ArgumentException))]
        public void TestDeactivateItemSupplier()
        {
            //Arrange This is a known item supplier
            int          itemID       = 100002;
            int          supplierID   = 100005;
            ItemSupplier itemSupplier = new ItemSupplier();

            //Act
            _itemSupplierManager.DeactivateItemSupplier(itemID, supplierID);
            //Assert should throw exception
            itemSupplier = _itemSupplierManager.RetrieveItemSupplier(itemID, supplierID);
            Assert.AreEqual(_itemSupplierManager.RetrieveItemSupplier(itemID, supplierID).ItemSupplierActive, false);
        }
コード例 #26
0
        internal static ItemSupplier GetByItemIdAndSupplierId(int itemId, int supId)
        {
            ItemSupplier isup = new ItemSupplier();

            using (var db = new ADDbContext())
            {
                if (db.ItemSupplier.Where(x => x.item.Id == itemId && x.supplier.Id == supId).Any())
                {
                    isup = db.ItemSupplier.Include("item").Include("supplier").Where(x => x.item.Id == itemId && x.supplier.Id == supId).FirstOrDefault();
                }
            }
            return(isup);
        }
        public int InsertItemSupplier(ItemSupplier itemSupplier)
        {
            int listCount = _itemSuppliers.Count;

            _itemSuppliers.Add(itemSupplier);

            if (_itemSuppliers.Count == listCount + 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
コード例 #28
0
        internal static void SetPriceById(int isId, double newprice)
        {
            ItemSupplier itsu = new ItemSupplier();

            using (var db = new ADDbContext())
            {
                if (db.ItemSupplier.Where(x => x.Id == isId).Any())
                {
                    itsu = db.ItemSupplier.Where(x => x.Id == isId).FirstOrDefault();
                }

                itsu.UnitPrice = newprice;
                db.SaveChanges();
            }
        }
コード例 #29
0
        public async Task <IActionResult> CreateItemSuppliers([FromBody] ItemSupplier itemSupplier)
        {
            var item = await this.repository.GetItemSupplier(itemSupplier.ItemId, itemSupplier.SupplierId);

            if (item != null)
            {
                return(BadRequest("Error - This supplier already belongs to this item!"));
            }
            var supplierCreated = await this.repository.Add(itemSupplier);

            if (supplierCreated == null)
            {
                return(BadRequest("Error - Item Supplier NOT created"));
            }
            return(Ok(itemSupplier));
        }
コード例 #30
0
        private void DgItemSupplier_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            _itemSupplier = (ItemSupplier)dgItemSupplier.SelectedItem;

            var itemSupplyManager = new frmAddItemSupplierForItem(_item, _itemSupplier, EditMode.Edit);
            var result            = itemSupplyManager.ShowDialog();

            if (result == true)
            {
                LoadControls(_item);
                LoadItemSupplierGrid();
            }
            else
            {
                return;
            }
        }