Example #1
0
 private void frmProduct_Load(object sender, EventArgs e)
 {
     gridUS1.Source = productBus.GetAll();
     gridUS1.MapColumn("ID", "Mã hàng hóa");
     gridUS1.MapColumn("Name", "Tên hàng hóa");
     gridUS1.MapColumn("DVT", "Đơn vị tính");
     gridUS1.MapColumn("SoLuong", "Số lượng");
     gridUS1.MapColumn("DonGiaNhap", "Đơn giá nhập");
     gridUS1.MapColumn("DonGiaBan", "Đơn giá bán");
     gridUS1.VisibleColumn("DaXoa", false);
     gridUS1.VisibleColumn("GhiChu", false);
 }
        public IActionResult Index()
        {
            var products   = ProductBus.GetAll().Result.ToList();
            var categories = CategoryBus.GetAll().Result.ToList();

            foreach (var product in products)
            {
                product.Category = categories.SingleOrDefault(x => x.Id == product.CategoryId);
            }
            ViewBag.Products = products;

            return(View());
        }
 private void LoadAll()
 {
     gridUS1.Source = null;
     if (isFind)
     {
         var rs = productBus.FindByName(gridUS1.ThongTinTimKiem);
         if (rs == null)
         {
             MessageBox.Show("Lỗi khi tải dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.Dispose();
             return;
         }
         if (rs.Count == 0)
         {
             return;
         }
         gridUS1.Source = rs;
     }
     else
     {
         var rs = productBus.GetAll();
         if (rs == null)
         {
             MessageBox.Show("Lỗi khi tải dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
         if (rs.Count == 0)
         {
             return;
         }
         gridUS1.Source = rs;
     }
     gridUS1.MapColumn("ID", "Mã hàng hóa");
     gridUS1.MapColumn("Name", "Tên hàng hóa");
     gridUS1.MapColumn("DVT", "Đơn vị tính");
     gridUS1.MapColumn("SoLuong", "Số lượng");
     gridUS1.MapColumn("DonGiaNhap", "Đơn giá nhập");
     gridUS1.MapColumn("DonGiaBan", "Đơn giá bán");
     gridUS1.VisibleColumn("DaXoa", false);
     gridUS1.VisibleColumn("GhiChu", false);
 }
        private void frmStartProgram_Load(object sender, EventArgs e)
        {
            Thread th = new Thread(() =>
            {
                try
                {
                    var rs = bus.GetAll();
                    if (programBus.CountHTTT() == 0)
                    {
                        programBus.AddDefaultHTTT("Tiền mặt");
                        programBus.AddDefaultHTTT("Chuyển khoản");
                        programBus.AddDefaultHTTT("Tiền mặt/ Chuyển Khoản");
                        programBus.AddDefaultAccount("admin", "123456");
                    }
                    if (rs != null)
                    {
                        success?.Invoke(this, EventArgs.Empty);
                    }
                    else
                    {
                        this.Invoke(new Action(() =>
                        {
                            MessageBox.Show("Có lỗi trong quá trình kết nối đến cơ sở dữ liệu !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.Close();
                        }));
                    }
                }
                catch
                {
                    this.Invoke(new Action(() =>
                    {
                        MessageBox.Show("Có lỗi trong quá trình kết nối đến cơ sở dữ liệu !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }));
                }
            });

            th.SetApartmentState(ApartmentState.STA);
            th.Start();
        }