コード例 #1
0
ファイル: OrderExportService.cs プロジェクト: imatary/work
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List <OrderExport> GetOrderExports()
 {
     using (var context = new StockACEntities())
     {
         return(context.OrderExports.ToList());
     }
 }
コード例 #2
0
 /// <summary>
 /// Trả về danh sách
 /// </summary>
 /// <returns></returns>
 public List <OrderImportDetail> GetOrderImportDetails()
 {
     using (var context = new StockACEntities())
     {
         return(context.OrderImportDetails.ToList());
     }
 }
コード例 #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);
        }
コード例 #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());
     }
 }
コード例 #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());
     }
 }
コード例 #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());
        }
コード例 #7
0
ファイル: UnitService.cs プロジェクト: imatary/work
        /// <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());
            //}
        }
コード例 #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());
            }
        }
コード例 #9
0
ファイル: FormReports.cs プロジェクト: imatary/work
 /// <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;
     }
 }
コード例 #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);
        }
コード例 #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 = "";
        }
コード例 #12
0
ファイル: FormMain.cs プロジェクト: imatary/work
 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;
             }
         }
     }
 }
コード例 #13
0
ファイル: FormReports.cs プロジェクト: imatary/work
        /// <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();
            }
        }
コード例 #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);
            }
        }
コード例 #15
0
ファイル: FormAddColor.cs プロジェクト: imatary/work
 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);
             }
         }
     }
 }
コード例 #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);
            }
        }
コード例 #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());
        }
コード例 #18
0
ファイル: UnitService.cs プロジェクト: imatary/work
 public UnitService()
 {
     _context = new StockACEntities();
 }
コード例 #19
0
 public OrderImportDetailService()
 {
     _context = new StockACEntities();
 }
コード例 #20
0
 public ProductGroupService()
 {
     _context = new StockACEntities();
 }
コード例 #21
0
        /// <summary>
        /// Trả về danh sách
        /// </summary>
        /// <returns></returns>
        public List <ProductGroup> GetProductGroups()
        {
            var context = new StockACEntities();

            return(context.ProductGroups.ToList());
        }
コード例 #22
0
 public SuppliersService()
 {
     _context = new StockACEntities();
 }
コード例 #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());
        }
コード例 #24
0
        public List <Employee> GetAllEmployees()
        {
            var context = new StockACEntities();

            return(context.Employees.Include("Department").ToList());
        }
コード例 #25
0
 public EmployeeService()
 {
     _context = new StockACEntities();
 }
コード例 #26
0
 public DepartmentService()
 {
     _context = new StockACEntities();
 }
コード例 #27
0
ファイル: StockService.cs プロジェクト: imatary/work
        /// <summary>
        /// Trả về danh sách đơn vị
        /// </summary>
        /// <returns></returns>
        public List <Data.Stock> GetStocks()
        {
            var context = new StockACEntities();

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

            return(context.Departments.ToList());
        }
コード例 #29
0
ファイル: OrderExportService.cs プロジェクト: imatary/work
 public OrderExportService()
 {
     _context = new StockACEntities();
 }
コード例 #30
0
 public InventoryService()
 {
     _context = new StockACEntities();
 }