Пример #1
0
 public CommodityAnalysisModel GetList()
 {
     try
     {
         using (db = new IEDEntities())
         {
             var commoAnaModel = new CommodityAnalysisModel();
             var commoAnalysis = (from x in db.T_CommodityAnalysis where  !x.IsDeleted && x.ObjectType == (int)eObjectType.isCommodity select new ProAnaModel()
             {
                 Id = x.Id,
                 Name = x.Name,
                 Node = x.Node,
                 ObjectId = x.ObjectId,
                 ObjectType = x.ObjectType,
                 ParentId = x.ParentId,
                 Description = x.Description,
                 CreatedDate = x.CreatedDate
             });
             if (commoAnalysis != null)
             {
                 commoAnaModel.CommoAna.AddRange(commoAnalysis);
                 commoAnaModel.years.AddRange(commoAnalysis.Select(x => x.CreatedDate.Month).Distinct());
             }
             return(commoAnaModel);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
 public double CalculationMachineTMU(int equipmentId, int equipmentType, float distance, double stopPrecision, int applyPressure, double natureCut)
 {
     try
     {
         using (db = new IEDEntities())
         {
             var    eAtrr      = db.T_EquipmentAttribute.FirstOrDefault(x => !x.IsDeleted && x.EquipmentId == equipmentId);
             double machineTMU = 0;
             if (equipmentType == (int)eEquipType_Default.isSewingMachine)
             {
                 // tinh theo cong thuc may may
                 var RPM = double.Parse(eAtrr.Column1);
                 var St  = double.Parse(eAtrr.Column2);
                 var BST = (St / (RPM * 0.0006));
                 var SST = (BST * distance) + 18 + stopPrecision;
                 machineTMU = SST;
             }
             else
             {
                 // tinh theo cong thuc may cat
                 var F      = applyPressure;
                 var CT     = natureCut;
                 var Weight = double.Parse(eAtrr.Column1);
                 var BCT    = Math.Sqrt((Weight * 0.01) / applyPressure) * 27.8;
                 var C      = (BCT * natureCut * distance) + stopPrecision;
                 machineTMU = C;
             }
             return(Math.Round(machineTMU, 3));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #3
0
        private bool CheckExists(string name, string code, int Id, int CompanyId, IEDEntities db)
        {
            try
            {
                T_WorkShop objectExists = null;
                if (!string.IsNullOrEmpty(name))
                {
                    objectExists = db.T_WorkShop.FirstOrDefault(c => !c.IsDeleted && c.Id != Id && c.CompanyId == CompanyId && c.Name.Trim().ToUpper().Equals(name.Trim().ToUpper()));
                }
                else
                {
                    objectExists = db.T_WorkShop.FirstOrDefault(c => !c.IsDeleted && c.Id != Id && c.CompanyId == CompanyId && c.Code.Trim().ToUpper().Equals(code.Trim().ToUpper()));
                }

                if (objectExists == null)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
 public List <ModelSelectItem> GetListEquipmentType()
 {
     try
     {
         using (db = new IEDEntities())
         {
             List <ModelSelectItem> listModelSelect = new List <ModelSelectItem>();
             listModelSelect.Add(new ModelSelectItem()
             {
                 Value = 0, Name = "- - Chọn Loại Thiết Bị - -"
             });
             listModelSelect.AddRange(db.T_EquipmentType.Where(x => !x.IsDeleted).Select(x => new ModelSelectItem()
             {
                 Value = x.Id,
                 Name  = x.Name,
                 Data  = x.EquipTypeDefaultId ?? 0,
                 //Code = x.Code
             }));
             return(listModelSelect);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #5
0
        public List<ModelSelectItem> GetListTimeTypePrepareSelect(int CompanyId, int[] relationCompanyIds)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    var timeType = db.T_TimeTypePrepare.Where(x => !x.IsDeleted);
                    if (timeType != null && timeType.Count() > 0)
                    {
                        return timeType.Select(
                                    x => new ModelSelectItem()
                                    {
                                        Value = x.Id,
                                        Name = x.Name
                                    }).ToList();
                    }
                    else
                        return new List<ModelSelectItem>();
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        public ResponseBase ChangeInfo(int userId, string mail, string first, string last)
        {
            ResponseBase rs = new ResponseBase();

            try
            {
                using (var db = new IEDEntities())
                {
                    SUser user = db.SUsers.FirstOrDefault(x => x.Id == userId && !x.IsDeleted);
                    if (user == null)
                    {
                        rs.IsSuccess = false;
                        rs.Errors.Add(new Error()
                        {
                            MemberName = "change info", Message = "Tài Khoản đang thao tác không tồn tại. Vui lòng kiểm tra lại."
                        });
                    }
                    else
                    {
                        user.Email       = mail;
                        user.FisrtName   = first;
                        user.LastName    = last;
                        user.UpdatedUser = userId;
                        user.UpdatedDate = DateTime.Now;
                        db.SaveChanges();
                        rs.IsSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rs);
        }
Пример #7
0
        public List <ModelFeature> GetListFeatureByListRoleId(List <int> listRoleId, IEDEntities db)
        {
            List <ModelFeature> listFeature = null;

            try
            {
                if (listRoleId != null && listRoleId.Count > 0)
                {
                    var featureIds = (from x in db.SRolePermissions where !x.IsDeleted && !x.SFeature.IsDeleted && !x.SFeature.SModule.IsDeleted && listRoleId.Contains(x.RoleId) select x.FeatureId).Distinct();
                    if (featureIds != null)
                    {
                        listFeature = (from c in db.SFeatures
                                       where featureIds.Contains(c.Id)
                                       select new ModelFeature()
                        {
                            Id = c.Id,
                            FeatureName = c.FeatureName,
                            SystemName = c.SystemName,
                            ModuleId = c.ModuleId,
                            IsDefault = c.IsDefault
                        }).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listFeature);
        }
Пример #8
0
        public PagedList <TimePrepareModel> Gets(int timeTypeId, int startIndexRecord, int pageSize, string sorting)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    if (string.IsNullOrEmpty(sorting))
                    {
                        sorting = "Id DESC";
                    }

                    var pageNumber = (startIndexRecord / pageSize) + 1;
                    var timeTypes  = db.T_TimePrepare.Where(x => !x.IsDeleted && x.TimeTypePrepareId == timeTypeId && !x.T_TimeTypePrepare.IsDeleted).OrderByDescending(x => x.CreatedDate).
                                     Select(x => new TimePrepareModel()
                    {
                        Id   = x.Id,
                        Name = x.Name,
                        Code = x.Code,
                        TimeTypePrepareId   = x.TimeTypePrepareId,
                        TimeTypePrepareName = x.T_TimeTypePrepare.Name,
                        TMUNumber           = x.TMUNumber,
                        Description         = x.Description,
                    }).OrderBy(sorting).ToList();
                    return(new PagedList <TimePrepareModel>(timeTypes, pageNumber, pageSize));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #9
0
        private bool CheckExists(string keyword, int id, bool isCheckName, IEDEntities db)
        {
            try
            {
                T_TimeTypePrepare timeType = null;
                keyword = keyword.Trim().ToUpper();
                if (isCheckName)
                {
                    timeType = db.T_TimeTypePrepare.FirstOrDefault(x => !x.IsDeleted && x.Id != id && x.Name.Trim().ToUpper().Equals(keyword));
                }
                else
                {
                    timeType = db.T_TimeTypePrepare.FirstOrDefault(x => !x.IsDeleted && x.Id != id && x.Code.Trim().ToUpper().Equals(keyword));
                }

                if (timeType == null)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #10
0
 public List <T_File> GetManipulationFileById(int Id)
 {
     try
     {
         using (db = new IEDEntities())
         {
             var filesID = db.T_ManipulationFile.Where(x => !x.IsDeleted && x.ManipulationId == Id && !x.T_ManipulationLibrary.IsDeleted && !x.T_File.IsDeleted).Select(x => x.FileId).ToList();
             if (filesID != null && filesID.Count > 0)
             {
                 var files = db.T_File.Where(x => !x.IsDeleted && filesID.Contains(x.Id)).ToList();
                 if (files != null && files.Count() > 0)
                 {
                     return(files.ToList());
                 }
                 return(null);
             }
             else
             {
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #11
0
        public ResponseBase GetAllManipulation()
        {
            var result = new ResponseBase();

            try
            {
                using (db = new IEDEntities())
                {
                    var list = db.T_ManipulationLibrary.Where(x => !x.IsDeleted && !x.T_ManipulationTypeLibrary.IsDeleted).Select(x => new ManipulationLibraryModel()
                    {
                        Id                 = x.Id,
                        Code               = x.Code,
                        Name               = x.Name,
                        Description        = x.Description,
                        ManipulationTypeId = x.ManipulationTypeId,
                        isUseMachine       = x.T_ManipulationTypeLibrary.IsUseMachine,
                        StandardTMU        = x.StandardTMU,
                        UserTMU            = x.UserTMU
                    });
                    if (list != null && list.Count() > 0)
                    {
                        result.Data = list.ToList();
                    }
                    result.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #12
0
 public PagedList <ManipulationEquipmentModel> GetManipulationEquipment(int Id, int startIndexRecord, int pageSize, string sorting)
 {
     try
     {
         using (db = new IEDEntities())
         {
             if (string.IsNullOrEmpty(sorting))
             {
                 sorting = "Id DESC";
             }
             var manis = db.T_ManipulationEquipment.Where(x => !x.IsDeleted && x.ManipulationId == Id).OrderByDescending(x => x.CreatedDate).Select(x => new ManipulationEquipmentModel()
             {
                 Id             = x.Id,
                 ManipulationId = x.ManipulationId,
                 MachineTMU     = x.MachineTMU,
                 UserTMU        = x.UserTMU,
                 Note           = x.Note,
                 EquipmentId    = x.EquipmentId,
                 EquipmentName  = x.T_Equipment.Name
             }).OrderBy(sorting).ToList();
             var pageNumber = (startIndexRecord / pageSize) + 1;
             return(new PagedList <ManipulationEquipmentModel>(manis, pageNumber, pageSize));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #13
0
        public PagedList <LabourDivisionModel> GetList(int parentId, int startIndexRecord, int pageSize, string sorting)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    if (string.IsNullOrEmpty(sorting))
                    {
                        sorting = "CreatedDate ASC";
                    }

                    var objs = db.T_LabourDivision.Where(c => !c.IsDeleted && c.ParentId == parentId).OrderByDescending(x => x.CreatedDate).Select(x => new LabourDivisionModel()
                    {
                        Id            = x.Id,
                        LineId        = x.LineId,
                        LineName      = x.T_Line.Name,
                        WorkShopId    = x.T_Line.WorkShopId,
                        WorkShopName  = string.Empty,
                        TechProVer_Id = x.TechProVer_Id,
                        ParentId      = x.ParentId,
                        LastEditer    = x.UpdatedUser != null ? x.SUser1.UserName : x.SUser.UserName,
                        LastEditTime  = x.UpdatedDate != null ? x.UpdatedDate.Value : x.CreatedDate,
                        TotalPosition = x.TotalPosition
                    }).ToList();
                    var pageNumber = (startIndexRecord / pageSize) + 1;
                    return(new PagedList <LabourDivisionModel>(objs, pageNumber, pageSize));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #14
0
        public ResponseBase Delete(int Id)
        {
            ResponseBase rs;

            try
            {
                using (db = new IEDEntities())
                {
                    rs = new ResponseBase();
                    var obj = Get(Id);
                    if (obj != null)
                    {
                        obj.IsDeleted = true;
                        db.SaveChanges();
                        rs.IsSuccess = true;
                    }
                    else
                    {
                        rs.IsSuccess = false;
                        rs.Errors.Add(new Error()
                        {
                            MemberName = "Delete", Message = "Đối Tượng Đã Bị Xóa. Vui Lòng Kiểm Tra Lại"
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rs);
        }
Пример #15
0
        public ResponseBase Delete(int id, int userId)
        {
            ResponseBase result;

            try
            {
                result = new ResponseBase();
                using (var db = new IEDEntities())
                {
                    var menuObj = db.SMenus.FirstOrDefault(x => x.Id == id && !x.IsDeleted);
                    if (menuObj == null)
                    {
                        result.IsSuccess = false;
                        result.Errors.Add(new Error()
                        {
                            MemberName = "DeleteMenu", Message = "Menu đang thao tác không tồn tại. Vui lòng kiểm tra lại!"
                        });
                    }
                    else
                    {
                        menuObj.IsDeleted               = true;
                        menuObj.DeletedUser             = userId;
                        menuObj.DeletedDate             = DateTime.Now;
                        db.Entry <SMenu>(menuObj).State = EntityState.Modified;
                        db.SaveChanges();
                        result.IsSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #16
0
        public List <ModelSelectItem> GetListTimeTypePrepareByworkShopId(int id)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    var timeType = db.T_TimeTypePrepare.Where(x => !x.IsDeleted && x.IsPublic);

                    if (timeType != null && timeType.Count() > 0)
                    {
                        return(timeType.Select(
                                   x => new ModelSelectItem()
                        {
                            Value = x.Id,
                            Name = x.Name
                        }).ToList());
                    }
                    else
                    {
                        return(new List <ModelSelectItem>());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #17
0
        public ResponseBase Delete(int accountId, int actionUserId)
        {
            ResponseBase rs = null;

            try
            {
                using (var db = new IEDEntities())
                {
                    rs = new ResponseBase();
                    SUser user = db.SUsers.FirstOrDefault(x => x.Id == accountId && !x.IsDeleted);
                    if (user != null)
                    {
                        user.IsDeleted   = true;
                        user.DeletedUser = actionUserId;
                        user.DeletedDate = DateTime.Now;
                        db.SaveChanges();
                        rs.IsSuccess = true;
                    }
                    else
                    {
                        rs.IsSuccess = false;
                        rs.Errors.Add(new Error()
                        {
                            MemberName = "Delete Account", Message = "Tài Khoản đang thao tác không tồn tại. Vui lòng kiểm tra lại!"
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rs);
        }
Пример #18
0
        public PagedList <ModelEquipmentTypeAttribute> GetList(int startIndexRecord, int pageSize, string sorting, int equipmentTypeId)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    if (string.IsNullOrEmpty(sorting))
                    {
                        sorting = "CreatedDate DESC";
                    }

                    var objs = db.T_EquipmentTypeAttribute.Where(c => !c.IsDeleted && c.EquipmentTypeId == equipmentTypeId).OrderByDescending(x => x.CreatedDate).Select(c => new ModelEquipmentTypeAttribute()
                    {
                        Id                = c.Id,
                        OrderIndex        = c.OrderIndex,
                        IsUseForTime      = c.IsUseForTime,
                        EquipmentTypeId   = c.EquipmentTypeId,
                        EquipmentTypeName = c.T_EquipmentType.Name,
                        Name              = c.Name,
                        IsDefault         = c.IsDefault,
                    }).ToList();
                    var pageNumber = (startIndexRecord / pageSize) + 1;
                    return(new PagedList <ModelEquipmentTypeAttribute>(objs, pageNumber, pageSize));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #19
0
        public List <ModelModule> GetListModuleByListRoleId(List <int> listRoleId, IEDEntities db)
        {
            List <ModelModule> listModule = null;

            try
            {
                if (listRoleId != null && listRoleId.Count > 0)
                {
                    var moduleIds = (from x in db.SRolePermissions
                                     where listRoleId.Contains(x.RoleId) && !x.IsDeleted && !x.SModule.IsDeleted && x.SModule.IsShow && x.SModule.IsSystem
                                     select x.ModuleId).Distinct();
                    if (moduleIds != null)
                    {
                        listModule = (from c in db.SModules
                                      where moduleIds.Contains(c.Id)
                                      select new ModelModule()
                        {
                            Id = c.Id,
                            IsSystem = c.IsSystem,
                            SystemName = c.SystemName,
                            ModuleName = c.ModuleName,
                            ModuleUrl = c.ModuleUrl,
                            OrderIndex = c.OrderIndex,
                            Description = c.Description
                        }).OrderBy(x => x.OrderIndex).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listModule);
        }
Пример #20
0
        public List <ModelEquipmentTypeAttribute> GetEquipmentTypeAttributeByEquipmentTypeId(int equipmentTypeId)
        {
            List <ModelEquipmentTypeAttribute> equipmentTypeAttributes = null;

            try
            {
                using (db = new IEDEntities())
                {
                    equipmentTypeAttributes = db.T_EquipmentTypeAttribute.Where(c => !c.IsDeleted && c.EquipmentTypeId == equipmentTypeId).Select(c => new ModelEquipmentTypeAttribute()
                    {
                        Id                = c.Id,
                        Name              = c.Name,
                        EquipmentTypeId   = c.EquipmentTypeId,
                        EquipmentTypeName = c.T_EquipmentType.Name,
                        OrderIndex        = c.OrderIndex,
                        IsDefault         = c.IsDefault,
                        IsUseForTime      = c.IsUseForTime,
                    }).OrderBy(x => x.OrderIndex).ToList();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(equipmentTypeAttributes);
        }
Пример #21
0
        public ResponseBase DeleteById(int id, int userId)
        {
            ResponseBase rs;

            try
            {
                using (db = new IEDEntities())
                {
                    rs = new ResponseBase();
                    var obj = db.T_EquipmentType.FirstOrDefault(c => !c.IsDeleted && c.Id == id);
                    if (obj != null)
                    {
                        obj.IsDeleted   = true;
                        obj.DeletedUser = userId;
                        obj.DeletedDate = DateTime.Now;
                        db.SaveChanges();
                        rs.IsSuccess = true;
                    }
                    else
                    {
                        rs.IsSuccess = false;
                        rs.Errors.Add(new Error()
                        {
                            MemberName = "Delete", Message = "Đối Tượng Đã Bị Xóa,Vui Lòng Kiểm Tra Lại"
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(rs);
        }
Пример #22
0
 public void ChangeIsDefaultSatusOfListConfigByTableNameAndCompanyIdNotObjectId(string tableName, int companyId, int objectId, int actionUser)
 {
     using (var db = new IEDEntities())
     {
         try
         {
             var listConfig = (from x in db.SConfigs
                               where x.ConpanyId == companyId && x.TableName.Equals(tableName) && x.IsDefault && !x.IsDeleted && x.ObjectId != objectId
                               select x);
             if (listConfig != null)
             {
                 foreach (var config in listConfig)
                 {
                     config.IsDefault   = false;
                     config.UpdatedUser = actionUser;
                     config.UpdatedDate = DateTime.Now;
                     db.Entry <SConfig>(config).State = System.Data.Entity.EntityState.Modified;
                 }
                 db.SaveChanges();
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Пример #23
0
 public List <ModelSelectItem> GetListEquipmentTypeDefault()
 {
     try
     {
         using (db = new IEDEntities())
         {
             List <ModelSelectItem> objs = new List <ModelSelectItem>();
             objs.Add(new ModelSelectItem()
             {
                 Value = 0, Name = "-- Chọn mã bộ phận --"
             });
             objs.AddRange(db.T_EquipType_Default.Select(x => new ModelSelectItem()
             {
                 Value = x.Id, Name = x.Name
             }));
             objs.Add(new ModelSelectItem()
             {
                 Value = 0, Name = "Khác"
             });
             return(objs);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #24
0
 public List <ModelConfig> GetListModelConfigByTableNameAndCompanyId(string tableName, int companyId)
 {
     using (var db = new IEDEntities())
     {
         try
         {
             List <ModelConfig> listConfig = null;
             listConfig = (from c in db.SConfigs
                           where !c.IsDeleted && c.TableName == tableName && c.ConpanyId == companyId
                           select new ModelConfig()
             {
                 Id = c.Id,
                 TableName = c.TableName,
                 ObjectId = c.ObjectId,
                 IsHidden = c.IsHidden,
                 IsDefault = c.IsDefault
             }).ToList();
             return(listConfig);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Пример #25
0
        public ResponseBase Delete(int Id, int actionUserId, int companyId)
        {
            ResponseBase result;

            try
            {
                using (db = new IEDEntities())
                {
                    result = new ResponseBase();
                    var obj = db.HR_Employee.Where(c => c.CompanyId == companyId && !c.IsDeleted && c.Id == Id).FirstOrDefault();
                    if (obj == null)
                    {
                        result.IsSuccess = false;
                        result.Errors.Add(new Error()
                        {
                            MemberName = "Delete", Message = "Dữ liệu đang thao tác không tồn tại. Vui lòng kiểm tra lại!"
                        });
                    }
                    else
                    {
                        obj.IsDeleted   = true;
                        obj.DeletedUser = actionUserId;
                        obj.DeletedDate = DateTime.Now;
                        db.SaveChanges();
                        result.IsSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #26
0
 public ResponseBase Delete(int id, int acctionUserId)
 {
     try
     {
         using (db = new IEDEntities())
         {
             var result = new ResponseBase();
             var obj    = db.T_Customer.FirstOrDefault(x => !x.IsDeleted && x.Id == id);
             if (obj == null)
             {
                 result.IsSuccess = false;
                 result.Errors.Add(new Error()
                 {
                     MemberName = "Delete Customer Type", Message = "Khách hàng bạn đang thao tác đã bị xóa hoặc không tồn tại. Vui lòng kiểm tra lại !."
                 });
             }
             else
             {
                 obj.IsDeleted   = true;
                 obj.DeletedUser = acctionUserId;
                 obj.DeletedDate = DateTime.Now;
                 db.SaveChanges();
                 result.IsSuccess = true;
             }
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #27
0
 public List <ModelSelectItem> GetListWorkShop()
 {
     try
     {
         using (db = new IEDEntities())
         {
             List <ModelSelectItem> objs = new List <ModelSelectItem>();
             var workshops = db.T_WorkShop.Where(x => !x.IsDeleted).Select(x => new ModelSelectItem()
             {
                 Value = x.Id, Name = x.Name
             });
             if (workshops != null && workshops.Count() > 0)
             {
                 objs.AddRange(workshops);
             }
             else
             {
                 objs.Add(new ModelSelectItem()
                 {
                     Value = 0, Name = " Không có Dữ Liệu "
                 });
             }
             return(objs);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #28
0
        public PagedList <CustomerModel> GetList(string keyWord, int companyId, int[] relationCompanyId, int startIndexRecord, int pageSize, string sorting)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    if (string.IsNullOrEmpty(sorting))
                    {
                        sorting = "CreatedDate DESC";
                    }

                    List <CustomerModel> CustomerTypes = null;
                    if (string.IsNullOrEmpty(keyWord))
                    {
                        CustomerTypes = GetAll(sorting, companyId, relationCompanyId);
                    }
                    else
                    {
                        CustomerTypes = GetByKeyword(keyWord, companyId, relationCompanyId, sorting);
                    }

                    var pageNumber = (startIndexRecord / pageSize) + 1;
                    return(new PagedList <CustomerModel>(CustomerTypes, pageNumber, pageSize));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #29
0
        public List <ModelSelectItem> GetUserRolesModelByUserId(int userId, bool IsOwner, int companyId)
        {
            List <ModelSelectItem> roles = null;

            try
            {
                using (db = new IEDEntities())
                {
                    if (IsOwner)
                    {
                        roles = db.SRoLes.Where(x => !x.IsDeleted && x.CompanyId == companyId).Select(x => new ModelSelectItem()
                        {
                            Name  = x.RoleName,
                            Value = x.Id
                        }).ToList();
                    }
                    else
                    {
                        roles = db.SUserRoles.Where(x => !x.IsDeleted && x.UserId == userId).Select(x => new ModelSelectItem()
                        {
                            Name  = x.SRoLe.RoleName,
                            Value = x.SRoLe.Id
                        }).ToList();
                    }
                    return(roles);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #30
0
        public List <ModelSelectItem> GetSelectItem(int companyId, int[] relationCompanyId)
        {
            try
            {
                using (db = new IEDEntities())
                {
                    var listModelSelect = new List <ModelSelectItem>();
                    var productTypes    = db.T_ProductGroup.Where(x => !x.IsDeleted && (x.CompanyId == null || x.CompanyId == companyId || relationCompanyId.Contains(x.CompanyId ?? 0)))
                                          .OrderByDescending(x => x.CreatedDate)
                                          .Select(
                        x => new ModelSelectItem()
                    {
                        Value = x.Id,
                        Name  = x.Name
                    }).ToList();

                    //if (productTypes != null && productTypes.Count() > 0)
                    //{
                    //    listModelSelect.Add(new ModelSelectItem() { Value = 0, Name = " - -  Chọn nhóm mã hàng  - - " });
                    listModelSelect.AddRange(productTypes);
                    //}
                    //else
                    //    listModelSelect.Add(new ModelSelectItem() { Value = 0, Name = "  Không có nhóm mã hàng  " });
                    return(listModelSelect);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }