示例#1
0
        private void ProductButton_Click(object sender, EventArgs e)
        {
            Button ProductButton = sender as Button;

            int ProductID = Convert.ToInt32(ProductButton.Tag);

            TblProduct ProductDetails = new TblProduct();

            if (CheckProductIsAddedAlready(ProductID))
            {
                int     Quantity = Convert.ToInt32(dgvSales.Rows[RowIndex].Cells["Quantity"].Value);
                decimal Price    = Convert.ToInt32(dgvSales.Rows[RowIndex].Cells["Price"].Value);

                Quantity++;

                decimal Sum = Convert.ToDecimal(Quantity * Price);

                dgvSales.Rows[RowIndex].Cells["Quantity"].Value = Quantity;
                dgvSales.Rows[RowIndex].Cells["Sum"].Value      = Sum;

                lblTotal.Text = CalculateTotal(dgvSales).ToString("# ##0 UZS");
            }
            else
            {
                dgvSales.Rows.Add(ProductDetails.Name, 1, ProductDetails.Price, ProductDetails.Price * 1, ProductID);
                lblTotal.Text = CalculateTotal(dgvSales).ToString("# ##0 UZS");
            }
        }
 public void ShowEditForm(TblProduct product)
 {
     SidePanel.Height = btnEdit.Height;
     SidePanel.Top    = btnEdit.Top;
     editProdict.setModel(product);
     editProdict.BringToFront();
 }
示例#3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            TblProduct product = new TblProduct();

            product.Name     = tbxName.Text;
            product.Category = (int)cboCategory.SelectedValue;

            pde.TblProducts.Add(product);

            pde.SaveChanges();
            ManagerForm.instance.OpenAllProduct();
        }
示例#4
0
        //private void FormatListItem(object sender, ListControlConvertEventArgs e)
        //{
        //    string currentName = ((TblProduct)e.ListItem).Name;
        //    string currentPrice = ((TblProduct)e.ListItem).Price.ToString();
        //    string currentNamePadded = currentName.PadRight(30);

        //    e.Value = currentNamePadded + currentPrice;

        //}

        private void btnDeleteItem_Click(object sender, EventArgs e)
        {
            if (lstChosenProducts.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select at least one product to delete");

                return;
            }

            TblProduct selectedProduct = (TblProduct)lstChosenProducts.SelectedRows[0].DataBoundItem;

            ProductList.Remove(selectedProduct);
            refreshDVG();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            TblProduct product = new TblProduct();

            product.Name     = tbxName.Text;
            product.Price    = Int32.Parse(tbxPrice.Text);
            product.Category = (int)cboCategory.SelectedValue;
            product.Image    = imageBytes;

            pde.TblProducts.Add(product);
            pde.SaveChanges();

            tbxName.Text  = string.Empty;
            tbxPrice.Text = string.Empty;
            pbImage.Refresh();

            MessageBox.Show("Product added");

            AllProducts ap = new AllProducts();

            ap.refreshDgv();
            //Application.OpenForms["AllProducts"];
            //((AllProducts)Forms["AllProducts"]).refreshDvg();
        }
示例#6
0
 public void setModel(TblProduct product)
 {
     tbxName.Text = product.Name;
 }