Exemplo n.º 1
0
        private void BtRowDelPro_Click(object sender, EventArgs e)
        {
            var pro = HelperProduct.GetProduct(proID);

            if (pro != null)
            {
                var result = MessageBox.Show("Bu işlem geri alınamaz. Yine de silinsin mi?", "SİL?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    r = Helper.CRUD(null, null, pro, null, null, EntityState.Deleted, "product");

                    if (r.isSuccess)
                    {
                        DisplayProducts();
                        DisplayOrders();
                        lblWarningPro.Visible = true;
                        lblWarningPro.Text    = "Ürün silindi!";
                    }
                    else
                    {
                        lblWarningPro.Visible = true;
                        lblWarningPro.Text    = r.Message;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void BtEditPro_Click(object sender, EventArgs e)
        {
            var pro            = HelperProduct.GetProduct(proID);
            int previousCateID = Convert.ToInt32(pro.cateID);

            if (pro != null)
            {
                int c = 0;
                if (!Helper.I(tbProName1.Text))
                {
                    pro.proName = tbProName1.Text; c++;
                }
                if (!Helper.I(tbPrePrice1.Text))
                {
                    pro.prePrice = Convert.ToDouble(tbPrePrice1.Text); c++;
                }
                if (!Helper.I(tbSalePrice1.Text))
                {
                    pro.salePrice = Convert.ToDouble(tbSalePrice1.Text); c++;
                }
                if (!Helper.I(tbStock1.Text))
                {
                    pro.quantity = Convert.ToInt32(tbStock1.Text); c++;
                }
                pro.cateID = Convert.ToInt32(cbCategory1.SelectedValue);
                if (previousCateID != pro.cateID)
                {
                    c++;
                }

                r = Helper.CRUD(null, null, pro, null, null, EntityState.Modified, "product");
                if (r.isSuccess)
                {
                    tbProName1.Clear(); cbCategory1.SelectedIndex = 0;
                    tbPrePrice1.Clear(); tbSalePrice1.Clear(); tbStock1.Clear();
                    DisplayProducts();
                    DisplayOrders();

                    if (c != 0)
                    {
                        lblWarningPro.Visible = true;
                        lblWarningPro.Text    = "Ürün bilgileri düzenlendi!";
                    }
                }

                else
                {
                    lblWarningPro.Visible = true;
                    lblWarningPro.Text    = r.Message;
                }
            }

            gbEditPro.Enabled = false;
        }
Exemplo n.º 3
0
        private void BtCompleteOrder_Click(object sender, EventArgs e)
        {
            bool result = Helper.I(tbQuantity.Text);

            if (result)
            {
                MessageBox.Show("Adet bilgisini giriniz!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                int custID = HelperCustomer.GetCustomerID(cbCustomers.GetItemText(cbCustomers.SelectedItem));
                var pro    = HelperProduct.GetProduct(sellProID);

                if (pro != null)
                {
                    if (pro.quantity < Convert.ToInt32(tbQuantity.Text))
                    {
                        if (pro.quantity == 0)
                        {
                            MessageBox.Show("Bu ürün tükenmiştir!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show($"Bu üründen stokta {pro.quantity} adet kaldı!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    else
                    {
                        Orders ord = new Orders {
                            piece      = Convert.ToInt32(tbQuantity.Text),
                            orderDate  = DateTime.Now.Date,
                            productID  = sellProID,
                            customerID = custID
                        };

                        r = Helper.CRUD(null, null, null, ord, null, EntityState.Added, "order");
                        if (r.isSuccess)
                        {
                            pro.quantity -= Convert.ToInt32(tbQuantity.Text);
                            rr            = Helper.CRUD(null, null, pro, null, null, EntityState.Modified, "product");
                        }

                        tbQuantity.Clear();
                        DisplayProducts();
                        DisplayOrders();
                    }
                }
            }
        }
Exemplo n.º 4
0
        void SubDisplayOrders(List <OrderModel> list)
        {
            foreach (var item in list)
            {
                string ctName = HelperCate.GetCate(Convert.ToInt32(HelperProduct.GetProduct(Convert.ToInt32(item.Products.productID)).cateID)).cateName;

                dgvOrders.Rows.Add(item.Customers.cFirstName + " " + item.Customers.cLastName,
                                   ctName, item.Products.proName, item.piece, item.Products.salePrice,
                                   Convert.ToDateTime(item.orderDate).ToShortDateString());

                profit += (Convert.ToDouble(item.Products.salePrice) - Convert.ToDouble(item.Products.prePrice));
            }
            lblProfit.Text = profit.ToString();
        }
Exemplo n.º 5
0
        private void DgvSellPro_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            gbSellPro.Visible = true;
            string sellProName = null, sellProPrice = null, sellProExp = null;

            if (dgvSellPro.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
            {
                dgvSellPro.CurrentRow.Selected = true;
                sellProName  = dgvSellPro.Rows[e.RowIndex].Cells["sellProName"].FormattedValue.ToString();
                sellProPrice = dgvSellPro.Rows[e.RowIndex].Cells["sellProPrice"].FormattedValue.ToString();
                sellProExp   = dgvSellPro.Rows[e.RowIndex].Cells["sellProExp"].FormattedValue.ToString();
            }

            sellProID          = HelperProduct.GetProductID(sellProName, Convert.ToDouble(sellProPrice), sellProExp);
            tbSelectedPro.Text = HelperProduct.GetProduct(sellProID).proName;
        }
Exemplo n.º 6
0
        private void DgvProducts_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (command == "updProduct")
            {
                int proID = 0;
                if (dgvProducts.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                {
                    dgvProducts.CurrentRow.Selected = true;
                    proID = Convert.ToInt32(dgvProducts.Rows[e.RowIndex].Cells["productID"].FormattedValue.ToString());
                }

                var pro = HelperProduct.GetProduct(proID);
                if (pro != null)
                {
                    FormUpdatePro f = new FormUpdatePro(pro);
                    f.Show();
                    this.Hide();
                }
            }

            else if (command == "delProduct")
            {
                int proID = 0;
                if (dgvProducts.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                {
                    dgvProducts.CurrentRow.Selected = true;
                    proID = Convert.ToInt32(dgvProducts.Rows[e.RowIndex].Cells["productID"].FormattedValue.ToString());
                }

                var pro = HelperProduct.GetProduct(proID);
                if (pro != null)
                {
                    if (HelperOrderDet.SoldProductsList().Contains(proID))
                    {
                        MessageBox.Show("Bu ürün daha önce satıldığı için listeden çıkaramazsınız!");
                    }
                    else
                    {
                        var result = HelperProduct.CUD(pro, EntityState.Deleted);
                        MessageBox.Show(result == true ? "Ürün başarıyla silindi!" : "HATA!");
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void BtAddToBasket_Click(object sender, EventArgs e)
        {
            int empID = Convert.ToInt32(cBoxEmployee.SelectedValue);
            int proID = Convert.ToInt32(cBoxProduct.SelectedValue);
            var pro   = HelperProduct.GetProduct(proID);

            if (pro != null)
            {
                if (!Helper.isNumber(tbQuantity.Text) || Convert.ToInt32(tbQuantity.Text) <= 0)
                {
                    btAddToBasket.Enabled = false;
                    MessageBox.Show("Hatalı giriş yaptınız!");
                }

                else if (pro.quantity < Convert.ToInt32(tbQuantity.Text))
                {
                    if (pro.quantity == 0)
                    {
                        MessageBox.Show("Bu ürün tükenmiştir!");
                    }
                    else
                    {
                        MessageBox.Show($"Bu üründen stokta {pro.quantity} adet kaldı!");
                    }
                }

                else
                {
                    if (!openOrder)
                    {
                        Orders ord = new Orders {
                            orderDate   = DateTime.Now.Date,
                            orderStatus = "Açık",
                            amount      = 0,
                            customerID  = cusID
                        };

                        var result1 = HelperOrder.CUD(ord, EntityState.Added);
                        if (result1)
                        {
                            openOrder = true;
                            OrderDetails ordDet = new OrderDetails {
                                productID       = proID,
                                priceEach       = HelperProduct.GetProduct(proID).proPrice,
                                quantityOrdered = Convert.ToInt32(tbQuantity.Text),
                                orderID         = ord.orderID,
                                employeeID      = empID
                            };

                            var result2 = HelperOrderDet.CUD(ordDet, EntityState.Added);
                            if (result2)
                            {
                                btFinishOrder.Enabled = true;
                                MessageBox.Show("Ürün sepete eklendi!");
                                ord.amount += ordDet.priceEach * ordDet.quantityOrdered;
                                HelperOrder.CUD(ord, EntityState.Modified);
                            }
                            else
                            {
                                MessageBox.Show("HATA!");
                            }
                        }
                    }

                    else
                    {
                        OrderDetails ordDet = new OrderDetails {
                            productID       = proID,
                            priceEach       = pro.proPrice,
                            quantityOrdered = Convert.ToInt32(tbQuantity.Text),
                            orderID         = HelperOrder.GetOrderList().Count,
                            employeeID      = empID
                        };

                        var ord    = HelperOrder.GetOrder(Convert.ToInt32(ordDet.orderID));
                        var result = HelperOrderDet.CUD(ordDet, EntityState.Added);
                        if (result)
                        {
                            btFinishOrder.Enabled = true;
                            MessageBox.Show("Ürün sepete eklendi!");
                            ord.amount += ordDet.priceEach * ordDet.quantityOrdered;
                            HelperOrder.CUD(ord, EntityState.Modified);
                        }
                        else
                        {
                            MessageBox.Show("HATA!");
                        }
                    }

                    pro.quantity -= Convert.ToInt32(tbQuantity.Text);
                    HelperProduct.CUD(pro, EntityState.Modified);
                }
            }
        }