Esempio n. 1
0
        private void DialogWindowsVender_Load(object sender, EventArgs e)
        {
            List <Vendor> vendors = SingletonVender.Instance().Vendors;

            //dataGridView1.DataSource = vendors;

            dataGridView1.Rows.Clear();
            dataGridView1.ColumnCount        = 6;
            dataGridView1.Columns[0].Name    = "Id";
            dataGridView1.Columns[0].Visible = false;

            dataGridView1.Columns[1].Name = "รหัส";
            dataGridView1.Columns[2].Name = "ชื่อ";
            dataGridView1.Columns[3].Name = "ที่อยู่";
            dataGridView1.Columns[4].Name = "เบอร์โทร";
            dataGridView1.Columns[5].Name = "ราคาสินค้า";
            dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            var columns = (from t in vendors
                           where t.Enable == true
                           select new
            {
                Id = t.Id,
                Code = t.Code,
                Name = t.Name,
                Address = t.Address,
                Tel = t.Tel,
                CostType = t.POCostType.Name
            }).ToList();

            foreach (var item in columns)
            {
                dataGridView1.Rows.Add(item.Id, item.Code, item.Name, item.Address, item.Tel, item.CostType);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Enter Vendor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void textBoxVendorCode_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:
                List <Vendor> vendors = SingletonVender.Instance().Vendors;
                string        code    = textBoxVendorCode.Text.Trim();
                Vendor        data    = vendors.FirstOrDefault(w => w.Enable == true && w.Code == code);
                if (data != null)
                {
                    BinddingVendor(data.Id);
                }
                else
                {
                    dataGridView1.Rows.Clear();
                    dataGridView1.Refresh();

                    textBoxVendorCode.Text = "";
                    textBoxVendorName.Text = "";
                    _VendorId = 0;
                }
                break;

            default:
                break;
            }
        }
Esempio n. 3
0
        public void BinddingVendor(int id)
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            _VendorId = id;
            List <Vendor> vendors = SingletonVender.Instance().Vendors;
            var           data    = vendors.SingleOrDefault(w => w.Id == id);

            textBoxVendorCode.Text = data.Code;
            textBoxVendorName.Text = data.Name;
            /// Get สินค้าห้องของเสีย
            IEnumerable <int> allProductInVendor = Singleton.SingletonProduct.Instance().Products.Where(w => w.Enable == true && w.FKVender == _VendorId).Select(w => w.Id).Distinct().ToList <int>();

            using (SSLsEntities db = new SSLsEntities())
            {
                var waste = db.WasteWarehouse.Where(w => w.Enable == true && allProductInVendor.Contains(w.FKProduct)).ToList();
                /// ตรวจพบสินค้า vendor ในห้องของเสีย
                foreach (var item in waste)
                {
                    IEnumerable <int> fkProductDtls = item.WasteWarehouseDetails.Where(w => w.Enable == true).Select(w => w.FKProductDetails).Distinct().ToList <int>();
                    /// Bindding Data Grid
                    foreach (int idProDtl in fkProductDtls)
                    {
                        decimal inQty  = 0;
                        decimal outQty = 0;
                        try
                        {
                            inQty  = db.WasteWarehouseDetails.Where(w => w.Enable == true && w.FKProductDetails == idProDtl && w.IsInOrOut == true).Sum(w => w.QtyUnit);
                            outQty = db.WasteWarehouseDetails.Where(w => w.Enable == true && w.FKProductDetails == idProDtl && w.IsInOrOut == false).Sum(w => w.QtyUnit);
                        }
                        catch (Exception)
                        {
                            outQty = 0;
                        }
                        if (inQty - outQty == 0)
                        {
                            continue;
                        }
                        /// from ห้องของเสีย
                        var getProdDtl = Singleton.SingletonProduct.Instance().ProductDetails.SingleOrDefault(w => w.Id == idProDtl);
                        dataGridView1.Rows.Add
                        (
                            idProDtl,
                            getProdDtl.Code,
                            getProdDtl.Products.ThaiName,
                            getProdDtl.ProductUnit.Name,
                            Library.ConvertDecimalToStringForm(inQty - outQty),
                            Library.ConvertDecimalToStringForm(inQty - outQty),// ยอดที่ต้องคืน
                            getProdDtl.PackSize,
                            Library.ConvertDecimalToStringForm(getProdDtl.CostOnly),
                            Library.ConvertDecimalToStringForm(getProdDtl.CostOnly * (inQty - outQty)),
                            "-");
                    }
                }
                // คำนวน
                CalSummary();
            }
        }
        public void BinddingVendor(int id)
        {
            _VendorId = id;
            List <Vendor> vendors = SingletonVender.Instance().Vendors;
            var           data    = vendors.SingleOrDefault(w => w.Id == id);

            textBoxVendorCode.Text = data.Code;
            textBoxVendorName.Text = data.Name;
        }
        public void BinddingVendor(int id)
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            _VendorId = id;
            List <Vendor> vendors = SingletonVender.Instance().Vendors;
            var           data    = vendors.SingleOrDefault(w => w.Id == id);

            textBoxVendorCode.Text = data.Code;
            textBoxVendorName.Text = data.Name;
        }
        public void BinddingVendor(int id)
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            _VendorId = id;
            List <Vendor> vendors = SingletonVender.Instance().Vendors;
            var           data    = vendors.SingleOrDefault(w => w.Id == id);

            textBoxVendorCode.Text = data.Code;
            textBoxVendorName.Text = data.Name;
            /// Get สินค้าห้องของเสีย
            IEnumerable <int> allProductInVendor = Singleton.SingletonProduct.Instance().Products.Where(w => w.Enable == true && w.FKVender == _VendorId).Select(w => w.Id).Distinct().ToList <int>();

            using (SSLsEntities db = new SSLsEntities())
            {
                var waste = db.WasteWarehouse.Where(w => w.Enable == true && allProductInVendor.Contains(w.FKProduct) && w.QtyUnit > 0).ToList();
                /// ตรวจพบสินค้า vendor ในห้องของเสีย
                foreach (var item in waste)
                {
                    IEnumerable <int> fkProductDtls = item.WasteWarehouseDetails.Where(w => w.Enable == true && w.LastResultUnit > 0).Select(w => w.FKProductDetails).Distinct().ToList <int>();
                    /// Bindding Data Grid
                    foreach (var last in fkProductDtls)
                    {
                        var getLast = item.WasteWarehouseDetails.Where(w => w.Enable == true && w.FKProductDetails == last).OrderByDescending(w => w.CreateDate).FirstOrDefault();
                        // get ค่าจากใบทำคืนที่ ยังไม่คอนเฟิม
                        decimal qtyCNNotComplete = 0;
                        var     cnData           = db.CNWarehouseDetails.Where(w => w.Enable == true && w.FKProductDetails == last && w.CNWarehouse.ConfirmCNDate == null && w.CNWarehouse.Enable == true).ToList();
                        if (cnData != null)
                        {
                            qtyCNNotComplete = cnData.Sum(w => w.Qty);
                        }
                        /// from ห้องของเสีย
                        dataGridView1.Rows.Add
                        (
                            getLast.FKProductDetails,
                            getLast.ProductDetails.Code,
                            getLast.ProductDetails.Products.ThaiName,
                            getLast.ProductDetails.ProductUnit.Name,
                            Library.ConvertDecimalToStringForm(getLast.LastResultUnit),
                            Library.ConvertDecimalToStringForm(qtyCNNotComplete),// ยอดที่รอการคอนเฟิม หลังจากส่งคืน
                            getLast.Packsize,
                            Library.ConvertDecimalToStringForm(getLast.ProductDetails.CostAndVat),
                            Library.ConvertDecimalToStringForm(getLast.ProductDetails.CostAndVat * getLast.QtyUnit),
                            "-"
                        );
                    }
                }
            }
            TotalSummary();
        }