Пример #1
0
        private Product BLLProductToProduct(BLLProduct itemToMap)
        {
            JewType mapJewType = new JewType()
            {
                Name = itemToMap.JewType.Name
            };
            List <Gemstone> mapGemstones = new List <Gemstone>();

            if (itemToMap.Gemstone != null)
            {
                foreach (var gem in itemToMap.Gemstone)
                {
                    mapGemstones.Add(new Gemstone()
                    {
                        Name = gem.Name, Size = gem.Size, Colour = gem.Colour, Price = gem.Price
                    });
                }
            }
            decimal productPrice = itemToMap.Gemstone.Sum(x => x.Price);
            Product product      = new Product()
            {
                Name      = itemToMap.Name,
                Price     = productPrice,
                JewTypeId = itemToMap.JewTypeId,
                JewType   = mapJewType,
                Gemstone  = mapGemstones
            };

            return(product);
        }
        private void bttnadd_Click(object sender, EventArgs e)
        {
            int        parsedvalue;
            BLLProduct blll = new BLLProduct();
            DataTable  dt   = blll.checkallproducts(txtproduct.Text);

            if (txtproduct.Text == "" || txtprice.Text == "")
            {
                MessageBox.Show("input the required fields...");
            }

            else if (!int.TryParse(txtprice.Text, out parsedvalue))
            {
                lblmsg.Text = ("the input in price is invalid type integers...");
            }

            else if (dt.Rows.Count > 0)
            {
                MessageBox.Show("product already exists");
            }
            else
            {
                // values check condition is not finished..
                int i = blp.addproduct(Convert.ToInt32(cbocategory.SelectedValue.ToString()), txtproduct.Text, Convert.ToDecimal(txtprice.Text));
                if (i > 0)
                {
                    MessageBox.Show("Product Has Been Added");
                    gridview1();
                }
            }
        }
        protected void AdminProductGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow  row     = (GridViewRow)AdminProductGrid.Rows[e.RowIndex];
            Label        LabelID = (Label)row.FindControl("LabelProductID");
            TextBox      TxtName = (TextBox)row.FindControl("TextBoxProductName");
            DropDownList DropDownListCategory = (DropDownList)row.FindControl("DropDownListCategories");
            TextBox      TextBoxPrice         = (TextBox)row.FindControl("TextBoxPrice");
            CheckBox     CheckBoxStock        = (CheckBox)row.FindControl("CheckBoxStock");
            TextBox      TextBoxDescription   = (TextBox)row.FindControl("TextBoxDescription");

            BLLProduct.UpdateProduct(new EProduct
            {
                ProductID   = Convert.ToInt32(LabelID.Text.ToString()),
                ProductName = TxtName.Text.ToString(),
                CategoryID  = Convert.ToInt32(DropDownListCategory.SelectedItem.Text.ToString()),
                Price       = Convert.ToDecimal(TextBoxPrice.Text.ToString()),
                Stock       = CheckBoxStock.Checked,
                Description = TextBoxDescription.Text.ToString()
            });
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(submittedFilePath, true))
            {
                file.WriteLine("[" + DateTime.Now + "] DB PRODUCT UPDATED");
            }
            AdminProductGrid.EditIndex = -1;
            FillProductView();
            feedbackProduct.Text    = "Records Updated Succesfully !!!";
            feedbackProduct.Visible = true;
        }
Пример #4
0
        private BLLProduct ProductToBLLProduct(Product itemToMap)
        {
            BLLJewType mapJewType = new BLLJewType()
            {
                Id = itemToMap.JewType.Id, Name = itemToMap.JewType.Name
            };
            List <BLLGemstone> mapGemstones = new List <BLLGemstone>();

            if (itemToMap.Gemstone != null)
            {
                foreach (var gem in itemToMap.Gemstone)
                {
                    mapGemstones.Add(new BLLGemstone()
                    {
                        Id = gem.Id, Name = gem.Name, Size = gem.Size, Colour = gem.Colour
                    });
                }
            }

            BLLProduct bllProduct = new BLLProduct()
            {
                Id        = itemToMap.Id,
                Name      = itemToMap.Name,
                Price     = itemToMap.Price,
                JewTypeId = itemToMap.JewTypeId,
                JewType   = mapJewType,
                Gemstone  = mapGemstones
            };

            //i dont know: shoul I for each BLLGemstone assign bllProduct as product?
            return(bllProduct);
        }
Пример #5
0
        }/// <summary>

        /// map product from business layer to presentation layer
        /// </summary>
        /// <param name="itemToMap"></param>
        /// <returns></returns>
        private PLProduct BLLProductToPLProduct(BLLProduct itemToMap)
        {
            PLJewType mapJewType = new PLJewType()
            {
                Name = itemToMap.JewType.Name
            };
            List <PLGemstone> mapGemstones = new List <PLGemstone>();

            if (itemToMap.Gemstone != null)
            {
                foreach (var gem in itemToMap.Gemstone)
                {
                    mapGemstones.Add(new PLGemstone()
                    {
                        Name = gem.Name, Size = gem.Size, Colour = gem.Colour
                    });
                }
            }
            //product price from DB is mapped here
            PLProduct plProduct = new PLProduct()
            {
                Name      = itemToMap.Name,
                Price     = itemToMap.Price,
                JewTypeId = itemToMap.JewTypeId,
                JewType   = mapJewType,
                Gemstone  = mapGemstones
            };

            return(plProduct);
        }
Пример #6
0
        /// <summary>
        /// map item from presentation layer to business layer
        /// </summary>
        /// <param name="itemToMap"></param>
        /// <returns></returns>
        private BLLProduct PLProductToBLLProduct(PLProduct itemToMap)
        {
            BLLJewType mapJewType = new BLLJewType()
            {
                Name = itemToMap.JewType.Name
            };
            List <BLLGemstone> mapGemstones = new List <BLLGemstone>();

            //send information about price of each gemstone
            if (itemToMap.Gemstone != null)
            {
                foreach (var gem in itemToMap.Gemstone)
                {
                    mapGemstones.Add(new BLLGemstone()
                    {
                        Name = gem.Name, Size = gem.Size, Colour = gem.Colour, Price = gem.Price
                    });
                }
            }
            // no information about product price
            BLLProduct bllProduct = new BLLProduct()
            {
                Name      = itemToMap.Name,
                JewTypeId = itemToMap.JewTypeId,
                JewType   = mapJewType,
                Gemstone  = mapGemstones
            };

            //i dont know: shoul I for each BLLGemstone assign bllProduct as product?
            return(bllProduct);
        }/// <summary>
 protected void FillProductView()
 {
     AdminProductGrid.DataSource = BLLProduct.GetProduct();
     using (System.IO.StreamWriter file =
                new System.IO.StreamWriter(submittedFilePath, true))
     {
         file.WriteLine("[" + DateTime.Now + "] DB PRODUCT DATA PULLED");
     }
     AdminProductGrid.DataBind();
 }
Пример #8
0
        public BLLProduct GetById(int id)
        {
            Product getProductById = _myJewStore.GetById(id);

            if (getProductById != null)
            {
                BLLProduct bllProductId = ProductToBLLProduct(getProductById);
                return(bllProductId);
            }
            return(null);
        }
Пример #9
0
        public void Add(PLProduct newProduct)
        {
            if (IsTypeNull(newProduct))
            {
                Console.WriteLine("You need define product type");
                return;
            }
            BLLProduct productToAdd = PLProductToBLLProduct(newProduct);

            _jewService.Add(productToAdd);
        }
Пример #10
0
        public void FillGrid()
        {
            List <ELBasket> basket = BLLBasket.GetBasket();

            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(submittedFilePath, true))
            {
                file.WriteLine("[" + DateTime.Now + "] DB BASKET PULLED");
            }
            DataTable dt = new DataTable();

            dt.Columns.Add("Ürün");
            dt.Columns.Add("Miktar");
            dt.Columns.Add("Fiyat");
            dt.Columns.Add("Numara");
            if (basket != null)
            {
                noteID.Visible            = true;
                TextBoxNoteID.Visible     = true;
                payementType.Visible      = true;
                acceptButtonImage.Visible = true;
                welc.Text    = "Hoşgeldin " + name + " !  Sepetin tam burada !!";
                welc.Visible = true;
                foreach (ELBasket item in basket)
                {
                    DataRow  dr  = dt.NewRow();
                    EProduct pro = (EProduct)BLLProduct.SelectProduct(item.productId);
                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(submittedFilePath, true))
                    {
                        file.WriteLine("[" + DateTime.Now + "] DB PRODUCT DATA SELECTED");
                    }
                    dr["Ürün"]   = pro.ProductName;
                    dr["Miktar"] = item.productCount;
                    dr["Fiyat"]  = item.productCount * pro.Price;
                    dr["Numara"] = item.id;
                    dt.Rows.Add(dr);
                }
                BasketGrid.DataSource = dt;
                BasketGrid.DataBind();
            }
            else
            {
                welc.Text                 = "Sepetin şu an boş";
                welc.Visible              = true;
                noteID.Visible            = false;
                TextBoxNoteID.Visible     = false;
                payementType.Visible      = false;
                acceptButtonImage.Visible = false;
                BasketGrid.DataSource     = dt;
                BasketGrid.DataBind();
            }
        }
Пример #11
0
        private void gvProducts_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                int        productId  = int.Parse(gvProducts.Rows[e.RowIndex].Cells["colProductId"].Value.ToString());
                Product    product    = new Product();
                BLLProduct productBLL = new BLLProduct();
                product = productBLL.GetProductById(productId);

                lbName.Text        = product.ProductName;
                lbPrice.Text       = product.OriginalPrice.ToString();
                lbUnit.Text        = product.ProductUnit;
                lbDescription.Text = product.Description;
            }
        }
        protected void AdminProductGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridViewRow row     = (GridViewRow)AdminProductGrid.Rows[e.RowIndex];
            Label       LabelID = (Label)row.FindControl("Label1");

            BLLProduct.DeleteProduct(Convert.ToInt32(LabelID.Text));
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(submittedFilePath, true))
            {
                file.WriteLine("[" + DateTime.Now + "] DB PRODUCT DELETED");
            }
            FillProductView();
            feedbackProduct.Text    = "Records Deleted Succesfully !!!";
            feedbackProduct.Visible = true;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            EClient user = (EClient)Session["user"];

            if (user != null)
            {
                welc.Text    = "Hoşgeldin " + user.name + " !  İşte Yemeklerimiz";
                welc.Visible = true;
                if (!IsPostBack)
                {
                    ProductGrid.DataSource = BLLProduct.SelectProduct_Category(1);
                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(submittedFilePath, true))
                    {
                        file.WriteLine("[" + DateTime.Now + "] DB PRODUCTS SELECTED BY CATEGORY");
                    }
                    ProductGrid.DataBind();
                    aperatifGrid.DataSource = BLLProduct.SelectProduct_Category(2);
                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(submittedFilePath, true))
                    {
                        file.WriteLine("[" + DateTime.Now + "] DB PRODUCTS SELECTED BY CATEGORY");
                    }
                    aperatifGrid.DataBind();
                    IcecekGrid.DataSource = BLLProduct.SelectProduct_Category(3);
                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(submittedFilePath, true))
                    {
                        file.WriteLine("[" + DateTime.Now + "] DB PRODUCTS SELECTED BY CATEGORY");
                    }
                    IcecekGrid.DataBind();
                    tatlıGrid.DataSource = BLLProduct.SelectProduct_Category(4);
                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(submittedFilePath, true))
                    {
                        file.WriteLine("[" + DateTime.Now + "] DB PRODUCTS SELECTED BY CATEGORY");
                    }
                    tatlıGrid.DataBind();
                }
            }
            else
            {
                welc.Visible = false;
                Response.Redirect("~/Default.aspx");
            }
        }
Пример #14
0
        public PLProduct GetById(int id)
        {
            if (id <= 0)
            {
                Console.WriteLine("Id should be positive");
                return(null);
            }
            BLLProduct bllProductById = _jewService.GetById(id);

            if (bllProductById != null)
            {
                PLProduct plProductById = BLLProductToPLProduct(bllProductById);
                return(plProductById);
            }
            Console.WriteLine($"No product with id={id}");
            return(null);
        }
        protected void InsertProduct_Click(object sender, EventArgs e)
        {
            string  name  = ((TextBox)AdminProductGrid.FooterRow.FindControl("TextBoxInsertProductName")).Text.ToString();
            int     cat   = Convert.ToInt32(((DropDownList)AdminProductGrid.FooterRow.FindControl("DropDownListInsertCategory")).SelectedItem.Text.ToString());
            decimal price = Convert.ToDecimal(((TextBox)AdminProductGrid.FooterRow.FindControl("TextBoxInsertPrice")).Text.ToString());
            bool    stock = ((CheckBox)AdminProductGrid.FooterRow.FindControl("TextBoxInsertStock")).Checked;
            string  desc  = ((TextBox)AdminProductGrid.FooterRow.FindControl("TextBoxInsertDescription")).Text.ToString();

            BLLProduct.CreateProduct(name, cat, price, stock, desc);
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(submittedFilePath, true))
            {
                file.WriteLine("[" + DateTime.Now + "] DB PRODUCT INSERTED");
            }
            FillProductView();
            feedbackProduct.Text    = "Record Added Succesfully !!!";
            feedbackProduct.Visible = true;
        }
Пример #16
0
        private void bttnadd_Click(object sender, EventArgs e)
        {
            BLLProduct blll = new BLLProduct();
            DataTable  dt   = blll.checkallproducts(txtproduct.Text);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("product already exists");
            }
            else
            {
                // values check condition is not finished..
                int i = blp.addproduct(Convert.ToInt32(cbocategory.SelectedValue.ToString()), txtproduct.Text, Convert.ToDecimal(txtprice.Text));
                if (i > 0)
                {
                    MessageBox.Show("Product Has Been Added");
                }
            }
        }
Пример #17
0
        public void Add(BLLProduct newProduct)
        {
            int numberOfGems = newProduct.Gemstone.Count;

            //check jems number, error, if more than 10 gems in one product
            if (numberOfGems > 10)
            {
                Console.WriteLine($"Maximum 10 gems per product, but you have {numberOfGems}. Item add failed.");
                return;
            }
            Product itemToAdd = BLLProductToProduct(newProduct);
            //check if we have such type of product in DB, assign existing type
            JewType searchJewTypeInDB = _myJewStore.SearchByJewType(itemToAdd.JewType);

            if (searchJewTypeInDB != null)
            {
                itemToAdd.JewType = searchJewTypeInDB;
            }
            _myJewStore.Add(itemToAdd);
        }
Пример #18
0
        private void gvBills_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                pictureBox1.Enabled = false;
                pictureBox2.Enabled = false;
                btnEdit.Enabled     = true;

                int      billsID  = int.Parse(gvBills.Rows[e.RowIndex].Cells["colBillsID"].Value.ToString());
                Bill     bills    = new Bill();
                BLLBills bllBills = new BLLBills();
                bills = bllBills.GetBillsById(billsID);

                if (gvBills.Columns[e.ColumnIndex].Name == "colBillsDeleted")
                {
                    if (MessageBox.Show("Are you sure to delete: " + gvBills.Rows[e.RowIndex].Cells["colBillsId"].Value.ToString(), "Message", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        bllBills.Deleted(bills);
                        LoadGridBills();
                        gvProductsToBills.Rows.Clear();
                        return;
                    }
                }

                gvProductsToBills.Rows.Clear();
                foreach (BillDetail billsDetail in bills.BillDetails)
                {
                    Product    product    = new Product();
                    BLLProduct productBLL = new BLLProduct();
                    product = productBLL.GetProductById(billsDetail.ProductId);

                    gvProductsToBills.Rows.Add(product.ProductId, product.ProductName, billsDetail.RealPrice, billsDetail.Amounts, billsDetail.Sum, Properties.Resources.DeleteRed);
                }

                lbTotal.Text = bills.Total.ToString();
            }
        }
Пример #19
0
        private void gvProducts_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                int productId = int.Parse(gvProducts.Rows[e.RowIndex].Cells["colProductId"].Value.ToString());
                int rowIndex  = -1;

                Product    product    = new Product();
                BLLProduct productBLL = new BLLProduct();
                product = productBLL.GetProductById(productId);

                if (TestExistsProductInBills(gvProductsToBills, productId, ref rowIndex))
                {
                    gvProductsToBills.Rows[rowIndex].Cells["colAmounts"].Value = int.Parse(gvProductsToBills.Rows[rowIndex].Cells["colAmounts"].Value.ToString()) + 1;
                    gvProductsToBills.Rows[rowIndex].Cells["colTotal"].Value   = float.Parse(gvProductsToBills.Rows[rowIndex].Cells["colTotal"].Value.ToString()) + product.OriginalPrice;
                }
                else
                {
                    gvProductsToBills.Rows.Add(product.ProductId, product.ProductName, product.OriginalPrice, 1, product.OriginalPrice, Properties.Resources.DeleteRed);
                }

                lbTotal.Text = SumTotal().ToString();
            }
        }
Пример #20
0
        private void cboCategories_SelectedIndexChanged(object sender, EventArgs e)
        {
            BLLProduct productBLL = new BLLProduct();

            gvProducts.DataSource = productBLL.GetProductByCategoryId(int.Parse(cboCategories.SelectedValue.ToString()));
        }