Esempio n. 1
0
        /*เรียก dialog ของรายการสินค้า*/
        private void ManageList()
        {
            StockAsiaDrink.DialogSearchProductCO frm = new StockAsiaDrink.DialogSearchProductCO(txtProduct.Text.Trim());
            frm.ShowDialog();
            List<string> ProductId = new List<string>();
            List<string> ProductName = new List<string>();
            List<string> UnitSaleName = new List<string>();
            List<string> UnitPackname = new List<string>();
            List<ProductList> ProductList = new List<ProductList>();

            if (frm.DialogResult == DialogResult.OK)
            {
                ProductId = frm.GetProductId();
                ProductName = frm.GetProductName();
                UnitSaleName = frm.GetUnitSaleName();
                UnitPackname = frm.GetUnitPackName();

                int count = ProductId.Count;
                dgvDetail.ColumnCount = 12;
                FormatdgvDetail();

                for (int i = 0; i < count; i++)
                {
                    ProductList.Add(new ProductList
                    {
                        ProductId = ProductId[i],
                        ProductName = ProductName[i],
                        UnitPackname = UnitPackname[i],
                        UnitSaleName = UnitSaleName[i],
                        UnitPrice = Convert.ToDouble(Class.Function.CostTopReturn(ProductId[i])).ToString("N2")
                    });
                }
                var listPro = ProductList.Select(i => new { i.ProductId, i.ProductName, i.UnitPackname, i.UnitSaleName, i.UnitPrice }).Distinct().ToList();

                if (ProductListOld == null)
                {
                    foreach (var list in listPro)
                    {
                        ShowDialogAddProductDetail(list.ProductId, list.ProductName, "", list.UnitPackname, "", list.UnitSaleName, "", "กก.", list.UnitPrice);
                        ProductListOld.Add(new ProductList
                        {
                            ProductId = list.ProductId,
                            ProductName = list.ProductName,
                            UnitPackname = list.UnitPackname,
                            UnitSaleName = list.UnitSaleName,
                            UnitPrice = list.UnitPrice
                        });
                    }
                }
                else
                {
                    foreach (var list in listPro.Except(ProductListOld.Select(i => new { i.ProductId, i.ProductName, i.UnitPackname, i.UnitSaleName, i.UnitPrice }).Distinct().ToList()))
                    {
                        ShowDialogAddProductDetail(list.ProductId, list.ProductName, "", list.UnitPackname, "", list.UnitSaleName, "", "กก.", list.UnitPrice);
                        ProductListOld.Add(new ProductList
                        {
                            ProductId = list.ProductId,
                            ProductName = list.ProductName,
                            UnitPackname = list.UnitPackname,
                            UnitSaleName = list.UnitSaleName,
                            UnitPrice = list.UnitPrice
                        });
                    }
                }
            }
            ProductListOld.Clear();
        }
Esempio n. 2
0
        private void txtProduct_KeyDown(object sender, KeyEventArgs e)
        {
            //if (e.KeyCode == Keys.Enter) { SearchProduct(txtProduct); }
            if (e.KeyCode == Keys.Enter)
            {
                if (Class.Function.GetTextId(txtStock.Text) == null)
                {
                    MessageBox.Show("กรุณาเลือกผู้ขาย");
                    return;
                }

                StockAsiaDrink.DialogSearchProductCO frm = new StockAsiaDrink.DialogSearchProductCO(txtProduct.Text.Trim());
                frm.ShowDialog();
                List<string> ProductId = new List<string>();
                List<string> ProductName = new List<string>();
                List<string> UnitSaleName = new List<string>();
                List<string> UnitPackname = new List<string>();
                //List<string> UnitSalePrice = new List<string>();

                List<ProductList> ProductList = new List<ProductList>();

                if (frm.DialogResult == DialogResult.OK)
                {
                    ProductId = frm.GetProductId();
                    ProductName = frm.GetProductName();
                    UnitSaleName = frm.GetUnitSaleName();
                    UnitPackname = frm.GetUnitPackName();
                    //UnitSalePrice = frm.GetUnitSalePrice();

                    int count = ProductId.Count;
                    dgvDetail.ColumnCount = 6;
                    FormatdgvDetail();

                    for (int i = 0; i < count; i++)
                    {
                        ProductList.Add(new ProductList
                        {
                            ProductId = ProductId[i],
                            ProductName = ProductName[i],
                            UnitPackname = UnitPackname[i],
                            UnitSaleName = UnitSaleName[i],
                            //UnitSalePrice = UnitSalePrice[i]
                        });
                    }
                    var listPro = ProductList.Select(i => new { i.ProductId, i.ProductName, i.UnitPackname, i.UnitSaleName }).Distinct().ToList();

                    if (ProductListOld == null)
                    {
                        foreach (var list in listPro)
                        {
                            ShowDialogAddProductDetail(list.ProductId, list.ProductName, "", list.UnitPackname, "", list.UnitSaleName);
                            ProductListOld.Add(new ProductList
                            {
                                ProductId = list.ProductId,
                                ProductName = list.ProductName,
                                UnitPackname = list.UnitPackname,
                                UnitSaleName = list.UnitSaleName,
                                //UnitSalePrice = list.UnitSalePrice
                            });
                        }
                    }
                    else
                    {
                        foreach (var list in listPro.Except(ProductListOld.Select(i => new { i.ProductId, i.ProductName, i.UnitPackname, i.UnitSaleName}).Distinct().ToList()))
                        {
                            ShowDialogAddProductDetail(list.ProductId, list.ProductName, "", list.UnitPackname, "", list.UnitSaleName);
                            ProductListOld.Add(new ProductList
                            {
                                ProductId = list.ProductId,
                                ProductName = list.ProductName,
                                UnitPackname = list.UnitPackname,
                                UnitSaleName = list.UnitSaleName,
                                //UnitSalePrice = list.UnitSalePrice
                            });
                        }
                    }
                }
                ProductListOld.Clear();
            }
        }
Esempio n. 3
0
        /*ดึงรายการสินค้าจาก Dialog รายการสินค้า เก็บลงใน list*/
        private void getDialogProduct()
        {
            StockAsiaDrink.DialogSearchProductCO frm = new StockAsiaDrink.DialogSearchProductCO(txtPNAME.Text.Trim());
            frm.ShowDialog();
            List<ListId> lProid = new List<ListId>();

            if (frm.DialogResult == DialogResult.OK)
            {
                for (int i = 0; i < frm.GetProductId ().Count; i++)
                {
                    lProid.Add(new ListId
                    {

                        ProductId = frm.GetProductId()[i],
                        ProductName = frm.GetProductName()[i],
                        QuantityPack = "",
                        UnitPackName = frm.GetUnitPackName()[i],
                        Quantity = "",
                        UnitSaleName = frm.GetUnitSaleName()[i],
                        SumWeight = "",
                        type = "",
                        price = "0.00",
                        total = "0.00",
                        sdate = "",
                        DetailW =""
                    });
                }

                var listPro = lProid.Select(i => new
                {
                    i.ProductId,
                    i.ProductName,
                    i.UnitPackName,
                    i.UnitSaleName,
                    i.QuantityPack,
                    i.Quantity,
                    i.SumWeight,
                    i.type,
                    i.price,
                    i.total,
                    i.sdate,
                }).Distinct().ToList();
                foreach (var list in listPro)
                {
                    loadGridSale(list.ProductId, list.ProductName, list.UnitPackName, list.UnitSaleName, list.price);
                    lProidOld.Add(new ListId
                    {
                        ProductId = list.ProductId,
                        ProductName = list.ProductName,
                        UnitPackName = list.UnitPackName,
                        UnitSaleName = list.UnitSaleName,
                        QuantityPack = list.QuantityPack,
                        Quantity = list.Quantity,
                        SumWeight = list.SumWeight,
                        type = list.type,
                        price = list.price,
                        total = list.total,
                        sdate = list.sdate,
                    });
                }

                if (lProidOld == null) { }
                else
                {
                    foreach (var list in listPro.Except(lProidOld.Select(i => new
                    {
                        i.ProductId,
                        i.ProductName,
                        i.UnitPackName,
                        i.UnitSaleName,
                        i.QuantityPack,
                        i.Quantity,
                        i.SumWeight,
                        i.type,
                        i.price,
                        i.total,
                        i.sdate
                    }).Distinct().ToList()))
                    {
                        loadGridSale(list.ProductId, list.ProductName, list.UnitPackName, list.UnitSaleName, list.price);
                        lProidOld.Add(new ListId
                        {
                            ProductId = list.ProductId,
                            ProductName = list.ProductName,
                            UnitPackName = list.UnitPackName,
                            UnitSaleName = list.UnitSaleName,
                            QuantityPack = list.QuantityPack,
                            Quantity = list.Quantity,
                            SumWeight = list.SumWeight,
                            type = list.type,
                            price = list.price,
                            total = list.total,
                            sdate = list.sdate
                        });
                    }
                }

                //setCalulate();
                SumReturn(TxtPriceTotal, 10);
            }
        }