Exemplo n.º 1
0
        //public async static Task AddProduct(string name, string gtin)
        //{
        //    // TODO Implement Adding Products to Outpan
        //}
        async Task <IDatabaseProduct> IProductSource.FindProductByCode(string code)
        {
            string url            = "https://" + $"api.outpan.com/v2/products/{code}?apikey=1e0dea2842c3bd80559b9ef0a8df187b";
            var    request        = WebRequest.Create(url);
            Stream responseStream = (await request.GetResponseAsync()).GetResponseStream();

            using (StreamReader sr = new StreamReader(responseStream))
            {
                JObject o    = JObject.Parse(sr.ReadToEnd());
                var     name = o["name"].ToString();
                var     gtin = o["gtin"].ToString();

                if (string.IsNullOrWhiteSpace(name))
                {
                    return(null);
                }

                //LocalCacheProductSource.AddProduct(name, gtin);

                BasicProduct p = new BasicProduct {
                    Name = name, Gtin = gtin
                };

                return(p);
            }
        }
Exemplo n.º 2
0
        private void btnBasicDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (SelectBasic)
                {
                    BasicProduct objBasic = objBasicProductDL.Get(cmbBasicProducts.SelectedValue.ToString());

                    if (objFormula.FormulaID != 0)
                    {
                        DialogResult dr = MessageBox.Show(this, "Are you sure you want to remove selected formula item? Click yes to remove", "Confirm Remove", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == DialogResult.Yes)
                        {
                            int x = objFormulaBasicProductDL.Delete(objFormula.FormulaID, objBasic.BasicProductCode, cmbBasicPart.SelectedItem.ToString());
                            if (x > 0)
                            {
                                bindBasicProduct.DataSource = objFormulaBasicProductDL.GetDataView_FormulaID(objFormula.FormulaID);
                                bindItemList.DataSource     = objFormulaDL.GetDataView_Items(objFormula.FormulaID);


                                txtBasicProductQty.Text        = "0.00";
                                cmbBasicPart.SelectedIndex     = -1;
                                cmbBasicProducts.SelectedIndex = -1;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public int Add(BasicProduct objBasicProduct, int DepID, int SectionID)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@BasicProductCode", objBasicProduct.BasicProductCode),
                    new SqlParameter("@BasicProductName", objBasicProduct.BasicProductName),
                    new SqlParameter("@BasicProductDescription", objBasicProduct.BasicProductDescription),
                    new SqlParameter("@BasicProductSubCatID", objBasicProduct.BasicProductSubCategory.CategoryID),
                    new SqlParameter("@BasicProductCatID", objBasicProduct.BasicProductCategory.CategoryID),
                    new SqlParameter("@BasicProductUnitID", objBasicProduct.BasicProductUnit.UnitID),
                    new SqlParameter("@BasicProductFormID", objBasicProduct.BasicProductForm.FormID),
                    new SqlParameter("@BasicProductAvgCost", objBasicProduct.BasicProductAVGCost),
                    new SqlParameter("@BasicProductStatus", objBasicProduct.BasicProductStatus),
                    new SqlParameter("@BasicProductType", objBasicProduct.BasicProductType),
                    new SqlParameter("@STDBatchSize", objBasicProduct.STDBatchSize),
                    new SqlParameter("@DepID", DepID),
                    new SqlParameter("@SectionID", SectionID)
                };

                return(Execute.RunSP_RowsEffected(Connection, "SPADD_BasicProduct", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(BasicProduct product, string[] selectedCategories)
        {
            try
            {
                if (ModelState.IsValid && selectedCategories != null)
                {
                    product.Categories = new List <BasicCategory>();

                    var selectedCategoriesHS = new HashSet <string>(selectedCategories);

                    foreach (var category in db.Categories)
                    {
                        if (selectedCategoriesHS.Contains(category.CategoryID.ToString()))
                        {
                            product.Categories.Add(category);
                        }
                    }

                    db.Products.Add(product);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException e)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator. (" + e.Message + ")");
            }
            PopulateCategoriesMultiSelectList(product.Categories);
            return(View(product));
        }
Exemplo n.º 5
0
        public void Get_Basic_Tariff_With_Double_Value_Kw()
        {
            var basicProduct = new BasicProduct();
            var cost         = basicProduct.CostCalulation(1400.60);

            Assert.Equal(368.132m, cost);
        }
Exemplo n.º 6
0
        public int Update(BasicProduct objBasicProduct, String OriginalBasicCode)
        {
            try
            {
                SqlParameter[] paramList = new SqlParameter[] {
                    new SqlParameter("@BasicProductCode", objBasicProduct.BasicProductCode),
                    new SqlParameter("@BasicProductName", objBasicProduct.BasicProductName),
                    new SqlParameter("@BasicProductDescription", objBasicProduct.BasicProductDescription),
                    new SqlParameter("@BasicProductSubCatID", objBasicProduct.BasicProductSubCategory.CategoryID),
                    new SqlParameter("@BasicProductCatID", objBasicProduct.BasicProductCategory.CategoryID),
                    new SqlParameter("@BasicProductUnitID", objBasicProduct.BasicProductUnit.UnitID),
                    new SqlParameter("@BasicProductFormID", objBasicProduct.BasicProductForm.FormID),
                    new SqlParameter("@BasicProductFormulaID", objBasicProduct.BasicProductFormula.FormulaID),
                    new SqlParameter("@BasicProductAvgCost", objBasicProduct.BasicProductAVGCost),
                    new SqlParameter("@BasicProductStatus", objBasicProduct.BasicProductStatus),
                    new SqlParameter("@BasicProductType", objBasicProduct.BasicProductType),
                    new SqlParameter("@Original_BasicProductCode", OriginalBasicCode)
                };

                return(Execute.RunSP_RowsEffected(Connection, "SPUPDATE_BasicProduct", paramList));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Exemplo n.º 7
0
        private void cmbMRType_SelectedIndexChanged(object sender, EventArgs e)
        {
            Material      objMat    = new Material();
            BasicProduct  objBasic  = new BasicProduct();
            FinishProduct objFinish = new FinishProduct();

            bindItemList.DataSource = null;
            objMRFinishhProductCollec.Clear();
            objMRMaterialCollec.Clear();
            objMRBasicProductCollec.Clear();

            try
            {
                if (cmbMRType.SelectedItem.Equals("Material"))
                {
                    cmbItem.DataSource    = objMaterialDL.GetDataView();
                    cmbItem.DisplayMember = "Material";
                    cmbItem.ValueMember   = "MaterialCode";



                    objMat = objMaterialDL.Get(cmbItem.SelectedValue.ToString());
                    if (objMat != null)
                    {
                        lblUnit.Text = objMat.MatUnit.UnitCode;
                    }
                }
                else if (cmbMRType.SelectedItem.Equals("Basic Products"))
                {
                    cmbItem.DataSource    = objBasicProductDL.GetDataView(true);
                    cmbItem.DisplayMember = "Code";
                    cmbItem.ValueMember   = "BasicProductCode";



                    objBasic = objBasicProductDL.Get(cmbItem.SelectedValue.ToString());
                    if (objBasic != null)
                    {
                        lblUnit.Text = objBasic.BasicProductUnit.UnitCode;
                    }
                }
                else if (cmbMRType.SelectedItem.Equals("Finish Products"))
                {
                    cmbItem.DataSource    = objFinishProductDL.GetDataView(1);
                    cmbItem.DisplayMember = "Code";
                    cmbItem.ValueMember   = "FinishProductCode";


                    objFinish = objFinishProductDL.Get(cmbItem.SelectedValue.ToString());
                    if (objFinish != null)
                    {
                        lblUnit.Text = objFinish.FinishProductPackingType.PackingTitle;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        private void cmbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            BasicProduct objBasic = new BasicProduct();

            try
            {
                if (cmbItem.SelectedValue != null)
                {
                    objBasic = objBasicProduct_DL.Get(cmbItem.SelectedValue.ToString());
                    if (objBasic != null)
                    {
                        lblUnit.Text         = objBasic.BasicProductUnit.UnitCode;
                        txtMaterialCode.Text = objBasic.BasicProductCode;
                    }
                    else
                    {
                        lblUnit.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        private void cmMaterial_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (cmMaterial.SelectedValue != null)
                {
                    objBasicProduct = objBasicProduct_DL.Get(cmMaterial.SelectedValue.ToString());

                    txtMaterialCode.Text = cmMaterial.SelectedValue.ToString();

                    lblUnit1.Text = objBasicProduct.BasicProductUnit.UnitCode;
                    lblUnit2.Text = objBasicProduct.BasicProductUnit.UnitCode;
                    lblUnit3.Text = objBasicProduct.BasicProductUnit.UnitCode;


                    LoadStock();
                    Load_BinCard();
                }
                else
                {
                    Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Exemplo n.º 10
0
        public async Task <WatchedBeer> ProductFromProductPage(BasicProduct basicProduct)
        {
            var client = Client();
            var html   = await client.GetStringAsync(basicProduct.LinkToProductPage);

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(html);

            var productInfo = htmlDoc.DocumentNode.FirstElementWithClass("div", "product__all-info");
            var siblingOfElementStartingWithInnerText = productInfo.SiblingOfElementStartingWithInnerText("dt", "Alkoholprosent");
            var alcohol = siblingOfElementStartingWithInnerText?.InnerText.ExtractDecimal();

            if (!alcohol.HasValue)
            {
                return(null);
            }

            var beerType = productInfo.SiblingOfElementStartingWithInnerText("dt", "Varetype")?.InnerText?.Split(',').LastOrDefault()?.Trim().SafeSubstring(64);

            return(new WatchedBeer
            {
                Name = htmlDoc.DocumentNode.FirstElementWithClass("div", "product")?.Descendants("h1").First().InnerText.RemoveEmptyCharacters().SafeSubstring(256),
                AlcoholPercentage = alcohol.Value,
                Type = beerType,
                //Brewery = productInfo.SiblingOfElementStartingWithInnerText("dt", "Produsent")?.InnerText,
                //Country = productInfo.SiblingOfElementStartingWithInnerText("dt", "Land")?.InnerText.RemoveEmptyCharacters().Split(',').First(),
                //Volume = (htmlDoc.DocumentNode.FirstElementWithClass("span", "product__amount")?.InnerText.ExtractDecimal() ?? 0) / 100,
                MaterialNumber = basicProduct.ProductNumber,
                Price = htmlDoc.DocumentNode.FirstElementWithClass("span", "product__price")?.InnerText.ExtractDecimal() ?? 0,
                BeerCategory = WatchedBeer.Category(beerType)
            });
        }
Exemplo n.º 11
0
        public void Get_Basic_Tariff_With_6000_Kw()
        {
            var basicProduct = new BasicProduct();
            var cost         = basicProduct.CostCalulation(6000);

            Assert.Equal(1380, cost);
        }
Exemplo n.º 12
0
        private void cmbBatch_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (cmbBatch.SelectedValue != null)
                {
                    objBatch = objBatch_DL.Get(cmbBatch.SelectedValue.ToString());
                    BatchID  = objBatch.BatchID;

                    objBasicProduct = objBasicProduct_DL.Get(objBatch_DL.Get_BasicProduct_Rework(objBatch.BatchID));


                    Load_Products();

                    Load_BatchActivity();
                }
                else
                {
                    dgvBatchActivity.AutoGenerateColumns = false;
                    objSourceBatchActivity.DataSource    = null;
                    dgvBatchActivity.DataSource          = objSourceBatchActivity;
                    objSourceBatchActivity.ResetBindings(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Exemplo n.º 13
0
        public ActionResult Create(BasicProduct product,string[] selectedCategories)
        {
            try
            {
                if (ModelState.IsValid && selectedCategories != null)
                {

                    product.Categories = new List<BasicCategory>();

                    var selectedCategoriesHS = new HashSet<string>(selectedCategories);

                    foreach (var category in db.Categories)
                    {
                        if (selectedCategoriesHS.Contains(category.CategoryID.ToString()))
                        {

                            product.Categories.Add(category);
                        }
                    }

                    db.Products.Add(product);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch(DataException e)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator. (" + e.Message +")");
            }
            PopulateCategoriesMultiSelectList(product.Categories);
            return View(product);
        }
Exemplo n.º 14
0
        public void CompareProducts_Returns_Valid_Comparison_First_Basic_Product()
        {
            // Arrange
            var basicProduct        = new BasicProduct();
            var packagedProduct     = new PackagedProduct();
            var comparisonService   = new ComparisonService();
            var validConsumption    = 3000;
            var expectedResultCount = 2;

            var expectedResult = new List <IProduct>()
            {
                basicProduct,
                packagedProduct
            };

            comparisonService.Add(basicProduct);
            comparisonService.Add(packagedProduct);

            // Act
            var actualResult = comparisonService.CompareProducts(validConsumption);

            // Assert
            Assert.IsNotNull(actualResult);
            Assert.AreEqual(expectedResultCount, actualResult.Count());
            Assert.IsTrue(actualResult.SequenceEqual(expectedResult));
        }
Exemplo n.º 15
0
        private void frmMRT_Load(object sender, EventArgs e)
        {
            try
            {
                BasicProduct objBasic = new BasicProduct();
                DataTable    dt       = new DataTable();

                bindItemList.DataSource = null;
                objMRBasicProductCollec.Clear();

                cmbDepartment.DataSource = objUserDepartments_DL.Get(CurrentUser.UserID);

                objStore = objStoreDL.Get(StoreID);

                txtStore.Text = objStore.StoreName;

                dt = objBasicProduct_DL.GetDataView();
                objSourceMaterial.DataSource = dt;

                cmbItem.DataSource = objSourceMaterial;



                objBasic = objBasicProduct_DL.Get(cmbItem.SelectedValue.ToString());
                if (objBasic != null)
                {
                    lblUnit.Text = objBasic.BasicProductUnit.UnitCode;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 16
0
        public void Get_Basic_Tariff_With_Negitive_Kw()
        {
            var basicProduct = new BasicProduct();
            var cost         = basicProduct.CostCalulation(-40);

            Assert.Equal(0, cost);
        }
Exemplo n.º 17
0
        //
        // GET: /Admin/Products/Edit/5

        public ActionResult Edit(int id)
        {
            BasicProduct product = db.Products.Find(id);

            db.Entry(product).Collection(x => x.Categories).Load();
            PopulateCategoriesMultiSelectList(product.Categories);
            return(View(product));
        }
Exemplo n.º 18
0
        public void CalculateAnnualCosts_Throws_Argument_Exception_Less_Then_Zero()
        {
            // Assert
            var inValidConsumption = -1;
            var product            = new BasicProduct();

            // Act
            product.CalculateAnnualCosts(inValidConsumption);
        }
Exemplo n.º 19
0
 public void AddBasicProduct(BasicProduct product)
 {
     if (GetBasicProductsByName(product.Name).Count() != 0)
     {
         return;
     }
     _context.BasicProducts.Add(product);
     Save();
 }
Exemplo n.º 20
0
        //
        // GET: /Admin/Products/Delete/5

        public ActionResult Delete(int id, bool?saveChangesError)
        {
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Unable to save changes. Try again, and if the problem persists see your system administrator.";
            }
            BasicProduct product = db.Products.Find(id);

            return(View(product));
        }
Exemplo n.º 21
0
        private void cmbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtGRNUnitCost.Text      = "0.00";
            cmbGRNNO.Text            = "";
            txtAvailableQty.Text     = "0.00";
            txtStockHoldingCost.Text = "0.00";
            txtGRNQty.Text           = "0.00";

            Material      objMat    = new Material();
            BasicProduct  objBasic  = new BasicProduct();
            FinishProduct objFinish = new FinishProduct();
            Store         objStore  = new Store();

            try
            {
                String ItemCode = "";
                txtUnit.Text = "";
                if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null)
                {
                    ItemCode = cmbItem.SelectedValue.ToString();
                }


                if (cmbStoreFrom.Items.Count > 0)
                {
                    objStore = (Store)cmbStoreFrom.SelectedItem;
                }

                if (!ItemCode.Equals(""))
                {
                    if (cmbMTNType.SelectedItem.Equals("Material"))
                    {
                        cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_Material(ItemCode, objStore.StoreID);
                        objMat       = objMaterialDL.Get(ItemCode);
                        txtUnit.Text = objMat.MatUnit.UnitName;
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                    {
                        cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_BasicProduct(ItemCode, objStore.StoreID);
                        objBasic            = objBasicProductDL.Get(ItemCode);
                        txtUnit.Text        = objBasic.BasicProductUnit.UnitName;
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                    {
                        cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_FinishProduct(ItemCode, objStore.StoreID);
                        objFinish           = objFinishProductDL.Get(ItemCode);
                        txtUnit.Text        = objFinish.FinishProductPackingType.PackingTitle;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 22
0
 public void AddNewProduct(NewProduct product)
 {
     _context.NewProducts.Add(product);
     if (GetNewProductsByName(product.Name).Count() == 10)
     {
         BasicProduct basicProduct = _mapper.Map <NewProduct, BasicProduct>(product);
         basicProduct.Id = Guid.NewGuid();
         AddBasicProduct(basicProduct);
     }
     Save();
 }
Exemplo n.º 23
0
        public ActionResult TopSelled(FormCollection collection)
        {
            var product = new BasicProduct();

            TryUpdateModel(product);
            if (ModelState.IsValid)
            {
                _productService.Update(product);
                return(PartialView(product));
            }
            return(PartialView(product));
        }
Exemplo n.º 24
0
        private void cmbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            Material      objMat    = new Material();
            BasicProduct  objBasic  = new BasicProduct();
            FinishProduct objFinish = new FinishProduct();

            try
            {
                if (cmbMRType.SelectedItem.Equals("Material"))
                {
                    if (cmbItem.SelectedValue != null)
                    {
                        objMat = objMaterialDL.Get(cmbItem.SelectedValue.ToString());
                        if (objMat != null)
                        {
                            lblUnit.Text = objMat.MatUnit.UnitCode;
                        }
                        else
                        {
                            lblUnit.Text = "";
                        }
                    }
                }
                else if (cmbMRType.SelectedItem.Equals("Basic Products"))
                {
                    objBasic = objBasicProductDL.Get(cmbItem.SelectedValue.ToString());
                    if (objBasic.BasicProductCode != null)
                    {
                        lblUnit.Text = objBasic.BasicProductUnit.UnitCode;
                    }
                    else
                    {
                        lblUnit.Text = "";
                    }
                }
                else if (cmbMRType.SelectedItem.Equals("Finish Products"))
                {
                    objFinish = objFinishProductDL.Get(cmbItem.SelectedValue.ToString());
                    if (objFinish.FinishProductCode != null)
                    {
                        lblUnit.Text = objFinish.FinishProductPackingType.PackingTitle;
                    }
                    else
                    {
                        lblUnit.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 25
0
        public void Name_Returns_Basic_Name()
        {
            // Assert
            var expectedName = "basic electricity tariff";

            // Act
            var product = new BasicProduct();

            // Arrange
            Assert.IsNotNull(product);
            Assert.IsNotNull(product.Name);
            Assert.AreEqual(expectedName, product.Name);
        }
Exemplo n.º 26
0
        public void CalculateAnnualCosts_Returns_22060()
        {
            // Assert
            var expectedAnnualCosts = 22060;
            var validConsumption    = 100000;
            var product             = new BasicProduct();

            // Act
            product.CalculateAnnualCosts(validConsumption);

            // Arrange
            Assert.IsNotNull(product);
            Assert.AreEqual(expectedAnnualCosts, product.AnnualCosts);
        }
Exemplo n.º 27
0
        private void cmbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            //txtGRNUnitCost.Text = "0.0";
            //  cmbGRNNO.Text = "";

            Material      objMat     = new Material();
            BasicProduct  objBasic   = new BasicProduct();
            FinishProduct objFinish  = new FinishProduct();
            Store         objStore   = new Store();
            Stock_DL      objStockDL = new Stock_DL(ConnectionStringClass.GetConnection());


            try
            {
                String ItemCode = "";
                txtUnit.Text         = "";
                txtAvailableQty.Text = "";
                if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null)
                {
                    ItemCode = cmbItem.SelectedValue.ToString();

                    objStore = (Store)cmbStoreFrom.SelectedItem;
                    if (cmbMTNType.SelectedItem.Equals("Material"))
                    {
                        objMat       = objMaterialDL.Get(ItemCode);
                        txtUnit.Text = objMat.MatUnit.UnitName;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_Material(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.Material).ToString();
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                    {
                        objBasic     = objBasicProductDL.Get(ItemCode);
                        txtUnit.Text = objBasic.BasicProductUnit.UnitName;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_BasicProduct(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.BasicProduct).ToString();
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                    {
                        objFinish    = objFinishProductDL.Get(ItemCode);
                        txtUnit.Text = objFinish.FinishProductPackingType.PackingTitle;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_FinishProduct(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.FinishProduct).ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 28
0
        public void CompareProducts_Throws_Argument_Exception_Less_Then_Zero()
        {
            // Arrange
            var basicProduct       = new BasicProduct();
            var packagedProduct    = new PackagedProduct();
            var comparisonService  = new ComparisonService();
            var inValidConsumption = -1;

            comparisonService.Add(basicProduct);
            comparisonService.Add(packagedProduct);

            // Act
            var actualResult = comparisonService.CompareProducts(inValidConsumption);
        }
        internal bool DrawMenu()
        {
            InventorySubMenu isubmenu = new InventorySubMenu();
            string           s;

            do
            {
                RepoDb <BasicProduct> db = new RepoDb <BasicProduct>();
                Console.WriteLine("1. Add Product");
                Console.WriteLine("2. Search Product");
                Console.WriteLine("3. Delete Product");
                Console.WriteLine("4. Update Product");
                int choice = Convert.ToInt32(Console.ReadLine());
                if (choice == 1)
                {
                    Console.WriteLine("Enter product code(integer)");
                    long code = Convert.ToInt64(Console.ReadLine());
                    Console.WriteLine("Enter product name(string)");
                    string name = Console.ReadLine();
                    Console.WriteLine("Enter product Manufacturer name(string)");
                    string man = Console.ReadLine();
                    Console.WriteLine("Enter product Manufacturing date");
                    string mdate = Console.ReadLine();
                    Console.WriteLine("Enter product Expiry date");
                    string edate = Console.ReadLine();
                    Console.WriteLine("Enter product Amount(integer)");
                    decimal      amount  = Convert.ToDecimal(Console.ReadLine());
                    BasicProduct product = new BasicProduct(code, name, man, mdate, edate, amount);

                    db.Add <BasicProduct>(product);
                }
                else if (choice == 2)
                {
                    Console.WriteLine("Enter product code(integer)");
                    long code = Convert.ToInt32(Console.ReadLine());
                    db.Get <BasicProduct>(code);
                }
                else if (choice == 3)
                {
                    Console.WriteLine("Enter ID to remove product");
                    long id = Convert.ToInt32(Console.ReadLine());
                    db.Remove <BasicProduct>(id);
                }
                Console.WriteLine("Want to perform another operation ?Then type yes");
                s = Console.ReadLine();
            } while (s == "yes");
            return(true);
        }
Exemplo n.º 30
0
        public void Add_Should_Add_Product()
        {
            // Arrange
            var comparisonService = new ComparisonService();
            var product           = new BasicProduct();

            // Act
            try
            {
                comparisonService.Add(product);
            }
            catch (Exception ex)
            {
                Assert.Fail($"Throwed an exception during adding process. Exception message: {ex.Message}");
            }
        }
Exemplo n.º 31
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         BasicProduct product = db.Products.Find(id);
         db.Products.Remove(product);
         db.SaveChanges();
     }
     catch (DataException)
     {
         return(RedirectToAction("Delete",
                                 new System.Web.Routing.RouteValueDictionary {
             { "id", id },
             { "saveChangesError", true }
         }));
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 32
0
 public ActionResult TopSelled(FormCollection collection)
 {
     var product = new BasicProduct();
     TryUpdateModel(product);
     if (ModelState.IsValid)
     {
         _productService.Update(product);
         return PartialView(product);
     }
     return PartialView(product);
 }