Ejemplo n.º 1
0
 private void ProductOutOfStockBtn_Click(object sender, EventArgs e)
 {
     this.productsPanel[4].BringToFront();
     ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
     products = new List <ServiceReference1.Product>(client.GetProductOutOfStock());
     setGridView4();
 }
Ejemplo n.º 2
0
 private void UpdateProductBtn_Click(object sender, EventArgs e)
 {
     this.productsPanel[3].BringToFront();
     ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
     products = new List <ServiceReference1.Product>(client.GetAllProduct());
     setGridView3();
 }
Ejemplo n.º 3
0
        private void LastYearSalesBtn_Click(object sender, EventArgs e)
        {
            this.billsPanel[3].BringToFront();
            var source = new BindingSource();

            ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
            source.DataSource        = client.GetLastYearSales();;
            dataGridView7.DataSource = source;
        }
Ejemplo n.º 4
0
 private void initOrderDetails()
 {
     QuantityInOrderTB.Text = "1";
     ProductInStockLB.Items.Clear();
     ProductInOrderLB.Items.Clear();
     TotalProductsTB.Text = "";
     TotalItemsTB.Text    = "";
     TotalAmountTB.Text   = "";
     ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
     products = new List <ServiceReference1.Product>(client.GetProductInStock());
     foreach (ServiceReference1.Product p in products)
     {
         ProductInStockLB.Items.Add("Id :- " + p.ProductId + " Name :- " + p.ProductName);
     }
     PaymentMethodLB.SelectedIndex = -1;
     bill = new Bill();
 }
Ejemplo n.º 5
0
        private void ViewProducsBtn_Click(object sender, EventArgs e)
        {
            this.productsPanel[1].BringToFront();
            var source = new BindingSource();

            ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
            List <ServiceReference1.Product>       pList  = new List <ServiceReference1.Product>(client.GetAllProduct());

            source.DataSource        = pList;
            dataGridView1.DataSource = source;
            dataGridView1.Columns["ProductId"].DisplayIndex        = 0;
            dataGridView1.Columns["ProductName"].DisplayIndex      = 1;
            dataGridView1.Columns["ProductPrice"].DisplayIndex     = 2;
            dataGridView1.Columns["TotalQuantity"].DisplayIndex    = 3;
            dataGridView1.Columns["QuantityAtShop"].DisplayIndex   = 4;
            dataGridView1.Columns["QuantityAtGodown"].DisplayIndex = 5;
            dataGridView1.Columns["Description"].DisplayIndex      = 6;
        }
Ejemplo n.º 6
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            if (ProductNameTB.Text == "")
            {
                MessageBox.Show("Please enter product name.");
            }
            else if (ProductPriceTB.Text == "")
            {
                MessageBox.Show("Please enter product price.");
            }
            else if (QuantityAtShopTB.Text == "")
            {
                MessageBox.Show("Please enter product quantity at shop.");
            }
            else if (QuantityAtGodownTB.Text == "")
            {
                MessageBox.Show("Please enter product quantity at godown.");
            }
            else
            {
                Product p = new Product(ProductNameTB.Text, Convert.ToInt32(ProductPriceTB.Text), Convert.ToInt32(QuantityAtShopTB.Text), Convert.ToInt32(QuantityAtGodownTB.Text), DescriptionTB.Text);
                ServiceReference1.Product ps = new ServiceReference1.Product();
                ps.ProductId        = p.ProductId;
                ps.ProductName      = p.ProductName;
                ps.ProductPrice     = p.ProductPrice;
                ps.TotalQuantity    = p.TotalQuantity;
                ps.QuantityAtShop   = p.QuantityAtShop;
                ps.QuantityAtGodown = p.QuantityAtGodown;
                ps.Description      = p.Description;
                ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
                int id = client.AddProduct(ps);
                if (id == -1)
                {
                    AddProductLbl.Text = "Error adding product.";
                }
                else
                {
                    AddProductLbl.Text = "Product added successfully with id " + id;
                }
            }

            initAddProduct();
        }
Ejemplo n.º 7
0
        private void ConfirmOrderBtn_Click(object sender, EventArgs e)
        {
            int id    = PaymentMethodLB.SelectedIndex;
            int count = ProductInOrderLB.Items.Count;

            if (count == 0)
            {
                MessageBox.Show("Please Add Product To Order.");
                return;
            }
            this.bill.calculateTotalAmount();
            TotalProductsTB.Text = bill.TotalProducts.ToString();
            TotalItemsTB.Text    = bill.TotalItems.ToString();
            TotalAmountTB.Text   = bill.TotalAmount.ToString();
            if (id == -1)
            {
                MessageBox.Show("Please Select Payment Method.");
                return;
            }
            bill.PaymentMethod = PaymentMethodLB.SelectedItem.ToString();
            ServiceReference1.Bill b = new ServiceReference1.Bill();
            b.BillId        = bill.BillId;
            b.BillDate      = bill.BillDate;
            b.TotalProducts = bill.TotalProducts;
            b.TotalItems    = bill.TotalItems;
            b.TotalAmount   = bill.TotalAmount;
            b.PaymentMethod = bill.PaymentMethod;
            b.Products      = bill.Products.ToArray();
            b.Quantity      = bill.Quantity.ToArray();
            ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
            int billId = client.AddBill(b);

            if (billId == -1)
            {
                OrderIDLbl.Text = "Error in adding to database.";
                return;
            }
            OrderIDLbl.Text = "Bill added with id :- " + billId;
            initOrderDetails();
            return;
        }
Ejemplo n.º 8
0
        private void TransferFromGodownTOSHopBtn_Click(object sender, EventArgs e)
        {
            int id = dataGridView2.SelectedRows.Count;

            if (id == 0)
            {
                MessageBox.Show("Please Select Product.");
                return;
            }
            if (QuantityTB.Text == "")
            {
                MessageBox.Show("Please Enter Quantity.");
                return;
            }
            ServiceReference1.Product p = products[dataGridView2.SelectedRows[0].Index];
            p.QuantityAtShop   += Convert.ToInt32(QuantityTB.Text);
            p.QuantityAtGodown -= Convert.ToInt32(QuantityTB.Text);
            ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
            client.UpdateProductQuantityAtShop(p.ProductId, p.QuantityAtShop);
            client.UpdateProductQuantityAtGodown(p.ProductId, p.QuantityAtGodown);
            QuantityTB.Text = "";
        }
Ejemplo n.º 9
0
        private void UpdateValueBtn_Click(object sender, EventArgs e)
        {
            int count = dataGridView3.SelectedRows.Count;

            if (count == 0)
            {
                MessageBox.Show("Please Select Product.");
                ProductParameters.SelectedIndex = -1;
                return;
            }
            ServiceReference1.Product p = products[dataGridView3.SelectedRows[0].Index];
            int id = ProductParameters.SelectedIndex;

            if (id == -1)
            {
                MessageBox.Show("Please Select Product Parameter.");
                ProductParameters.SelectedIndex = -1;
                return;
            }
            ServiceReference1.ProductServiceClient client = new ServiceReference1.ProductServiceClient();
            if (id == 0)
            {
                if (UpdateValueTB.Text != p.ProductName)
                {
                    p.ProductName = UpdateValueTB.Text;
                    client.UpdateProductName(p.ProductId, p.ProductName);
                }
            }
            else if (id == 1)
            {
                if (Convert.ToInt32(UpdateValueTB.Text) != p.ProductPrice)
                {
                    p.ProductPrice = Convert.ToInt32(UpdateValueTB.Text);
                    client.UpdateProductPrice(p.ProductId, p.ProductPrice);
                }
            }
            else if (id == 2)
            {
                if (Convert.ToInt32(UpdateValueTB.Text) != p.QuantityAtShop)
                {
                    p.TotalQuantity -= p.QuantityAtShop;
                    p.QuantityAtShop = Convert.ToInt32(UpdateValueTB.Text);
                    p.TotalQuantity += p.QuantityAtShop;
                    client.UpdateProductQuantityAtShop(p.ProductId, p.QuantityAtShop);
                    client.UpdateProductTotalQuantity(p.ProductId, p.TotalQuantity);
                }
            }
            else if (id == 3)
            {
                if (Convert.ToInt32(UpdateValueTB.Text) != p.QuantityAtGodown)
                {
                    p.TotalQuantity   -= p.QuantityAtGodown;
                    p.QuantityAtGodown = Convert.ToInt32(UpdateValueTB.Text);
                    p.TotalQuantity   += p.QuantityAtGodown;
                    client.UpdateProductQuantityAtGodown(p.ProductId, p.QuantityAtGodown);
                    client.UpdateProductTotalQuantity(p.ProductId, p.TotalQuantity);
                }
            }
            else if (id == 4)
            {
                if (UpdateValueTB.Text != p.Description)
                {
                    p.Description = UpdateValueTB.Text;
                    client.UpdateProductDescription(p.ProductId, p.Description);
                }
            }
        }