Esempio n. 1
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List <OrderExport> GetOrderExports()
 {
     using (var context = new StockACEntities())
     {
         return(context.OrderExports.ToList());
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List <OrderImportDetail> GetOrderImportDetails()
 {
     using (var context = new StockACEntities())
     {
         return(context.OrderImportDetails.ToList());
     }
 }
Esempio n. 3
0
        public List <InventoryView> GetAllInventories()
        {
            var context = new StockACEntities();
            List <InventoryView> inventories = (from inventory in context.Inventories
                                                join product in context.Products on inventory.ProductID equals product.ProductID
                                                join productGroup in context.ProductGroups on product.ProductGroupID equals productGroup.ProductGroupID
                                                //join stock in context.Stocks on product.StockID equals stock.StockID
                                                join unit in context.Units on product.UnitID equals unit.UnitID
                                                where inventory.QuantityExport > 0
                                                select new InventoryView()
            {
                ProductGroupID = product.ProductGroupID,
                ProductGroupName = productGroup.ProductGroupName,
                ProductID = product.ProductID,
                ProductName = product.ProductName,
                Price = (long)product.Price,
                QuantityFirst = (int)inventory.QuantityFirst,
                QuantityImport = (int)inventory.QuantityImport,
                QuantityExport = (int)inventory.QuantityExport,
                QuantityInventory = (int)inventory.QuantityInventory,
                InventoryDate = inventory.InventoryDate,
                UnitID = product.UnitID,
                UnitName = unit.UnitName,
                StockID = product.StockID,
            }).ToList();

            return(inventories);
        }
Esempio n. 4
0
 /// <summary>
 /// Danh sách Log
 /// </summary>
 /// <returns></returns>
 public List <Log> GetLogs()
 {
     using (var context = new StockACEntities())
     {
         return(context.Logs.OrderByDescending(log => log.LogDate).ToList());
     }
 }
Esempio n. 5
0
 public List <Inventory> GetQuantityInventories()
 {
     using (var context = new StockACEntities())
     {
         return(context.Inventories.Where(
                    inven => inven.QuantityInventory <= 5 && !string.IsNullOrEmpty(inven.QuantityInventory.ToString())).ToList());
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Trả về danh sách
        /// </summary>
        /// <returns></returns>
        public List <Employee> GetEmployees()
        {
            var context = new StockACEntities();

            return(context.Employees.Include("Department")
                   .Where(em => em.IsManagerStock == false || em.IsManagerStock == null)
                   .ToList());
        }
Esempio n. 7
0
        /// <summary>
        /// Trả về danh sách đơn vị
        /// </summary>
        /// <returns></returns>
        public List <Unit> GetUnits()
        {
            //using (var context=new StockACEntities())
            //{
            var context = new StockACEntities();

            return(context.Units.ToList());
            //}
        }
Esempio n. 8
0
        /// <summary>
        /// Danh sách user
        /// </summary>
        /// <returns></returns>
        public List <User> GetUsers()
        {
            using (var context = new StockACEntities())
            {
                //List<User> users = context.Users.Include("Employee")
                //    .Select(u => new {
                //        u.Employee.EmployeeName,
                //        u.LastLogin
                //    }).ToList();

                return(context.Users.ToList());
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Load danh sách nhóm hàng
 /// </summary>
 private void LoadGirdLookUpProductGroup()
 {
     using (var context = new StockACEntities())
     {
         var stocks = context.ProductGroups.ToList();
         gridLookUpEditProductGroups.Properties.View.OptionsBehavior.AutoPopulateColumns = false;
         gridLookUpEditProductGroups.Properties.DisplayMember = "ProductGroupName";
         gridLookUpEditProductGroups.Properties.ValueMember   = "ProductGroupID";
         gridLookUpEditProductGroups.Properties.View.BestFitColumns();
         gridLookUpEditProductGroups.Properties.PopupFormWidth = 406;
         gridLookUpEditProductGroups.Properties.DataSource     = stocks;
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Trả về thông tin user theo ID
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public User GetUserById(int userId)
        {
            using (var context = new StockACEntities())
            {
                //List<User> users = context.Users.Include("Employee")
                //    .Select(u => new {
                //        u.Employee.EmployeeName,
                //        u.LastLogin
                //    }).ToList();

                return(context.Users.FirstOrDefault(u => u.UserID == userId));
            }
            //return _context.Users.FirstOrDefault(u => u.UserID == userId);
        }
Esempio n. 11
0
        public void LoadStockForGirdLookup()
        {
            gridLookUpEditStock.Properties.View.OptionsBehavior.AutoPopulateColumns = false;
            gridLookUpEditStock.Properties.DisplayMember = "StockName";
            gridLookUpEditStock.Properties.ValueMember   = "StockID";
            gridLookUpEditStock.Properties.View.BestFitColumns();
            gridLookUpEditStock.Properties.PopupFormWidth = 300;
            using (var context = new StockACEntities())
            {
                gridLookUpEditStock.Properties.DataSource = context.Stocks.ToList();
            }


            // glKhoHang.Text = "";
        }
Esempio n. 12
0
 private void GetCurrentEmployeeName()
 {
     if (Program.CurrentUser != null)
     {
         string employeeId = Program.CurrentUser.EmployeeID;
         using (var context = new StockACEntities())
         {
             var employee = context.Employees.FirstOrDefault(e => e.EmployeeID == employeeId);
             if (employee != null)
             {
                 barItemUserName.Caption = employee.EmployeeName;
             }
         }
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Load danh sách Kho Hàng
        /// </summary>
        private void LoadDataForGridViewReportByStock(DateTime?startDate, DateTime?endDate)
        {
            _waitDialog.CreateWaitDialog();
            _waitDialog.SetWaitDialogCaption("Chương trình đang tải dữ liệu.\n Vui lòng chờ trong giây lát!");
            dockPanelReports.Text = Resources.TitleDockPanelReportByStock;

            using (var context = new StockACEntities())
            {
                var reportByStock = (from inventory in context.Inventories
                                     join product in context.Products on inventory.ProductID equals product.ProductID
                                     join productGroup in context.ProductGroups on product.ProductGroupID equals productGroup.ProductGroupID
                                     join unit in context.Units on product.UnitID equals unit.UnitID
                                     join stock in context.Stocks on product.StockID equals stock.StockID
                                     select new ReportByStockView()
                {
                    ProductGroupName = productGroup.ProductGroupName,
                    ProductID = product.ProductID,
                    ProductName = product.ProductName,
                    Price = (int)product.Price,
                    InventoryDate = inventory.InventoryDate,
                    UnitName = unit.UnitName,
                    StockName = stock.StockName,
                    Quantity = (int)inventory.QuantityExport,
                }).ToList();


                gridControl1.MainView = gridViewStocks;

                if (startDate != null && endDate != null)
                {
                    gridControl1.DataSource =
                        reportByStock.Where(inventory => inventory.InventoryDate >= startDate && inventory.InventoryDate <= endDate);
                }
                else
                {
                    gridControl1.DataSource = reportByStock;
                }

                if (gridControl1.DataSource != null)
                {
                    EnableButtonExportExelAndPrinter(true);
                }
                _reportViews = reportByStock;
                _waitDialog.CloseWait();
            }
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <ManagersView> GetManagers()
        {
            //            SELECT
            //Users.UserName AS Expr1,
            //Users.EmployeeID AS Expr2,
            //Departments.DepartmentName, Departments.DepartmentID
            //AS Expr3, Employees.*
            //FROM Departments
            //INNER JOIN Employees ON Departments.DepartmentID = Employees.DepartmentID
            //INNER JOIN Users ON Employees.EmployeeID = Users.EmployeeID
            //WHERE Employees.IsManagerStock=1

            //var inventories = (from inventory in context.Inventories
            //                       join product in context.Products on inventory.ProductID equals product.ProductID
            //                       join productGroup in context.ProductGroups on product.ProductGroupID equals productGroup.ProductGroupID
            //                       //join stock in context.Stocks on product.StockID equals stock.StockID
            //                       join unit in context.Units on product.UnitID equals unit.UnitID
            //        where product.StockID == stockId


            using (var context = new StockACEntities())
            {
                var managers = (from department in context.Departments
                                join employee in context.Employees on department.DepartmentID equals employee.DepartmentID
                                join user in context.Users on employee.EmployeeID equals user.EmployeeID
                                where employee.IsManagerStock == true
                                select new ManagersView()
                {
                    DepartmentName = department.DepartmentName,
                    UserName = user.UserName,
                    EmployeeCode = employee.EmployeeCode,
                    EmployeeID = employee.EmployeeID,
                    EmployeeName = employee.EmployeeName,
                    Alias = employee.Alias,
                    Sex = employee.Sex,
                    Address = employee.Address,
                    HomeTell = employee.HomeTell,
                    Mobile = employee.Mobile,
                    Fax = employee.Fax,
                    Email = employee.Email,
                    Birthday = employee.Birthday
                }).ToList();

                return(managers);
            }
        }
Esempio n. 15
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtColorName.Text))
     {
         XtraMessageBox.Show("Vui lòng nhập vào Tên màu", "THÔNG BÁO", MessageBoxButtons.OK,
                             MessageBoxIcon.Warning);
         txtColorName.Focus();
     }
     else
     {
         var color = new Color()
         {
             ColorName   = txtColorName.Text,
             Description = txtDescription.Text,
             ColorCode   = colorEditColorCode.Color.Name,
             IsActive    = checkEditIsActive.Checked,
         };
         using (var context = new StockACEntities())
         {
             try
             {
                 context.Colors.Add(color);
                 context.SaveChanges();
                 if (XtraMessageBox.Show("Thêm thành công.\n Bạn có muốn thêm mới Màu Sắc nữa không?", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                 {
                     ResetControls();
                 }
                 else
                 {
                     DialogResult = DialogResult.No;
                 }
             }
             catch (Exception ex)
             {
                 XtraMessageBox.Show(string.Format("Lỗi {0}", ex.Message), "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Esempio n. 16
0
        public List <ManagersView> GetEmployeeManagers()
        {
            //            SELECT
            //Users.UserName AS Expr1,
            //Users.EmployeeID AS Expr2,
            //Departments.DepartmentName, Departments.DepartmentID
            //AS Expr3, Employees.*
            //FROM Departments
            //INNER JOIN Employees ON Departments.DepartmentID = Employees.DepartmentID
            //INNER JOIN Users ON Employees.EmployeeID = Users.EmployeeID
            //WHERE Employees.IsManagerStock=1

            //var inventories = (from inventory in context.Inventories
            //                       join product in context.Products on inventory.ProductID equals product.ProductID
            //                       join productGroup in context.ProductGroups on product.ProductGroupID equals productGroup.ProductGroupID
            //                       //join stock in context.Stocks on product.StockID equals stock.StockID
            //                       join unit in context.Units on product.UnitID equals unit.UnitID
            //        where product.StockID == stockId


            using (var context = new StockACEntities())
            {
                var managers = (from department in context.Departments
                                join employee in context.Employees on department.DepartmentID equals employee.DepartmentID
                                where employee.IsManagerStock == true
                                select new ManagersView()
                {
                    EmployeeCode = employee.EmployeeCode,
                    EmployeeID = employee.EmployeeID,
                    EmployeeName = employee.EmployeeName,
                    Email = employee.Email,
                }).ToList();

                return(managers);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Trả về danh sách đơn vị
        /// </summary>
        /// <returns></returns>
        public List <Inventory> GetInventories()
        {
            var context = new StockACEntities();

            return(context.Inventories.ToList());
        }
Esempio n. 18
0
 public UnitService()
 {
     _context = new StockACEntities();
 }
Esempio n. 19
0
 public OrderImportDetailService()
 {
     _context = new StockACEntities();
 }
Esempio n. 20
0
 public ProductGroupService()
 {
     _context = new StockACEntities();
 }
Esempio n. 21
0
        /// <summary>
        /// Trả về danh sách
        /// </summary>
        /// <returns></returns>
        public List <ProductGroup> GetProductGroups()
        {
            var context = new StockACEntities();

            return(context.ProductGroups.ToList());
        }
Esempio n. 22
0
 public SuppliersService()
 {
     _context = new StockACEntities();
 }
Esempio n. 23
0
        /// <summary>
        /// Trả về danh sách
        /// </summary>
        /// <returns></returns>
        public List <Supplier> GetSuppliers()
        {
            var context = new StockACEntities();

            return(context.Suppliers.Include("Area").ToList());
        }
Esempio n. 24
0
        public List <Employee> GetAllEmployees()
        {
            var context = new StockACEntities();

            return(context.Employees.Include("Department").ToList());
        }
Esempio n. 25
0
 public EmployeeService()
 {
     _context = new StockACEntities();
 }
Esempio n. 26
0
 public DepartmentService()
 {
     _context = new StockACEntities();
 }
Esempio n. 27
0
        /// <summary>
        /// Trả về danh sách đơn vị
        /// </summary>
        /// <returns></returns>
        public List <Data.Stock> GetStocks()
        {
            var context = new StockACEntities();

            return(context.Stocks.ToList());
        }
Esempio n. 28
0
        /// <summary>
        /// Trả về danh sách
        /// </summary>
        /// <returns></returns>
        public List <Department> GetDepartments()
        {
            var context = new StockACEntities();

            return(context.Departments.ToList());
        }
Esempio n. 29
0
 public OrderExportService()
 {
     _context = new StockACEntities();
 }
Esempio n. 30
0
 public InventoryService()
 {
     _context = new StockACEntities();
 }