Exemplo n.º 1
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();
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List<OrderExportDetail> GetOrderExportDetails()
 {
     using (var context=new StockACEntities())
     {
         return context.OrderExportDetails.ToList();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List<OrderImport> GetOrderImports()
 {
     using (var context=new StockACEntities())
     {
         return context.OrderImports.ToList();
     }
 }
Exemplo n.º 6
0
 public List<Inventory> GetQuantityInventories()
 {
     using (var context=new StockACEntities())
     {
         return context.Inventories.Where(
                 inven => inven.QuantityInventory <= 5 && !string.IsNullOrEmpty(inven.QuantityInventory.ToString())).ToList();
     }
 }
Exemplo 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();
     //}    
 }
Exemplo 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();
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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;
             }
         } 
     }
 }
Exemplo 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 = "";
        }
Exemplo n.º 12
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();
            }
        }
Exemplo n.º 13
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;
            }    
        }
Exemplo n.º 14
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);
                    }
                }
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List<Supplier> GetSuppliers()
 {
     var context = new StockACEntities();
     return context.Suppliers.Include("Area").ToList();
 }
Exemplo n.º 16
0
 public SuppliersService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 17
0
 public InventoryService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 18
0
 public ManagersService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 19
0
 public LogService()
 {
     _context=new StockACEntities();
 }
Exemplo n.º 20
0
 public DepartmentService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 21
0
 public ProductService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 22
0
 public UserService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 23
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;
            }
        }
Exemplo n.º 24
0
 public OrderExportDetailService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 25
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List<Department> GetDepartments()
 {
     var context = new StockACEntities();
     return context.Departments.ToList();
 }
Exemplo n.º 26
0
 /// <summary>
 /// Trả về danh sách đơn vị
 /// </summary>
 /// <returns></returns>
 public List<Inventory> GetInventories()
 {
     var context = new StockACEntities();
     return context.Inventories.ToList();
 }
Exemplo n.º 27
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;
            }

        }
Exemplo n.º 28
0
 public EmployeeService()
 {
     _context = new StockACEntities();
 }
Exemplo n.º 29
0
 public List<Employee> GetAllEmployees()
 {
     var context = new StockACEntities();
     return context.Employees.Include("Department").ToList();
 }
Exemplo n.º 30
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List<Product> GetProducts()
 {
     var context = new StockACEntities();
     return context.Products.ToList();
 }