Ejemplo n.º 1
0
        //
        // CUSTOM FUNCTIONS
        //
        public DTO.SearchFilterData GetSearchFilter(int userId, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SearchFilterData data = new DTO.SearchFilterData();
            data.QuotationStatuses = new List <Support.DTO.QuotationStatus>();
            data.Seasons           = new List <Support.DTO.Season>();
            data.Factories         = new List <Support.DTO.Factory>();

            try
            {
                data.QuotationStatuses = supportFactory.GetQuotationStatus();
                data.Seasons           = supportFactory.GetSeason();
                data.Factories         = supportFactory.GetFactory(userId);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Ejemplo n.º 2
0
 public override DTO.SearchFormData GetDataWithFilter(Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
 {
     DTO.SearchFormData searchFormData = new DTO.SearchFormData();
     notification = new Library.DTO.Notification()
     {
         Type = Library.DTO.NotificationType.Success
     };
     totalRows = 0;
     try
     {
         int?   factoryID   = null;
         string season      = null;
         int?   weekNo      = null;
         string updatedDate = null;
         string updatorName = null;
         int    userId      = Convert.ToInt32(filters["userId"]);
         if (filters.ContainsKey("factoryID") && filters["factoryID"] != null)
         {
             factoryID = Convert.ToInt32(filters["factoryID"]);
         }
         if (filters.ContainsKey("season") && !string.IsNullOrEmpty(filters["season"].ToString()))
         {
             season = filters["season"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("weekNo") && filters["weekNo"] != null)
         {
             weekNo = Convert.ToInt32(filters["weekNo"]);
         }
         if (filters.ContainsKey("updatedDate") && !string.IsNullOrEmpty(filters["updatedDate"].ToString()))
         {
             updatedDate = filters["updatedDate"].ToString().Replace("'", "''");
         }
         if (filters.ContainsKey("updatorName") && !string.IsNullOrEmpty(filters["updatorName"].ToString()))
         {
             updatorName = filters["updatorName"].ToString().Replace("'", "''");
         }
         using (FactoryProductionStatusEntities context = CreateContext())
         {
             totalRows = context.FactoryProductionStatusMng_function_SearchFactoryProductionStatus(orderBy, orderDirection, userId, factoryID, season, weekNo, updatedDate, updatorName).Count();
             var result = context.FactoryProductionStatusMng_function_SearchFactoryProductionStatus(orderBy, orderDirection, userId, factoryID, season, weekNo, updatedDate, updatorName);
             searchFormData.Data = converter.DB2DTO_FactoryProductionStatusSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
         }
         searchFormData.Factories   = supportFactory.GetFactory(userId);
         searchFormData.Seasons     = supportFactory.GetSeason();
         searchFormData.WeekSeasons = supportFactory.GetWeekInSeason(Library.Helper.GetCurrentSeason());
         return(searchFormData);
     }
     catch (Exception ex)
     {
         notification.Type    = Library.DTO.NotificationType.Error;
         notification.Message = ex.Message;
         notification.DetailMessage.Add(ex.Message);
         if (ex.GetBaseException() != null)
         {
             notification.DetailMessage.Add(ex.GetBaseException().Message);
         }
         return(searchFormData);
     }
 }
Ejemplo n.º 3
0
        public DTO.SupportData GetSupportData(string formName, out Library.DTO.Notification notification)
        {
            DTO.SupportData data = new DTO.SupportData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            data.Factories                       = new List <Support.DTO.Factory>();
            data.MeetingLocations                = new List <DTO.MeetingLocation>();
            data.Users                           = new List <Support.DTO.User2>();
            data.Sales                           = new List <DTO.Sale>();
            data.employeeDepartmentDTOs          = new List <Support.DTO.EmployeeDepartmentDTO>();
            data.TimeRange                       = new List <string>();
            data.SCMAppointmentAttachedFileTypes = new List <Support.DTO.AppointmentAttachedFileType>();

            try
            {
                switch (formName)
                {
                case "calendar":
                    foreach (Support.DTO.MeetingLocation location in supportFactory.GetMeetingLocation())
                    {
                        if (location.MeetingLocationID == 1 || location.MeetingLocationID == 4)     //request Mr Luc AVT VIETNAM SHOWROOM AND AT FACTORY
                        {
                            data.MeetingLocations.Add(new DTO.MeetingLocation()
                            {
                                MeetingLocationID = location.MeetingLocationID, MeetingLocationNM = location.MeetingLocationNM, IsSelected = false
                            });
                        }
                    }
                    data.Factories = supportFactory.GetFactory();
                    break;

                case "editEvent":
                    data.Users = supportFactory.GetUsers2();
                    data.employeeDepartmentDTOs = supportFactory.GetDepartmentDTOs();
                    data.TimeRange = supportFactory.GetTimeRange();
                    data.SCMAppointmentAttachedFileTypes = supportFactory.GetAppointmentAttachedFileType();
                    using (SCMAgendaMngEntities context = CreateContext())
                    {
                        data.Sales = converter.DB2DTO_SaleList(context.SupportMng_Sale_View.Where(o => o.CompanyID.Value != 3).ToList());     // company different than AVT
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
            }
            return(data);
        }
Ejemplo n.º 4
0
        public DTO.FactoryAssignment.FormData GetFactoryAssignmentData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.FactoryAssignment.FormData data = new DTO.FactoryAssignment.FormData();
            data.SupportList           = new DTO.SupportData();
            data.SupportList.Factories = new List <Support.DTO.Factory>();
            data.Data = new DTO.FactoryAssignment.ProductDTO();
            data.Data.SubFactoryDTOs = new List <DTO.FactoryAssignment.SubFactoryDTO>();

            try
            {
                if (id > 0)
                {
                    using (Sample3MngEntities context = CreateContext())
                    {
                        data.Data = converter.DB2DTO_FactoryAssignment_Product(context.Sample3Mng_FactoryAssignment_Product_View.Include("Sample3Mng_FactoryAssignment_SubFactory_View").FirstOrDefault(o => o.SampleProductID == id));
                    }
                }
                data.SupportList.Factories = supportFactory.GetFactory();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Ejemplo n.º 5
0
        public DTO.SearchFilterData GetSearchFilter(int userId, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SearchFilterData data = new DTO.SearchFilterData();
            data.Employees = new List <Support.DTO.Employee>();
            data.FactoryRawMaterialSupplierList = new List <DTO.FactoryRawMaterialSupplier>();
            //data.SupplierList = new List<DTO.Supplier>();
            data.Locations = new List <Support.DTO.FactoryLocation>();
            data.Factories = new List <Support.DTO.Factory>();

            try
            {
                data.Employees = supportFactory.GetEmployee().ToList();
                data.Locations = supportFactory.GetFactoryLocation();
                data.Factories = supportFactory.GetFactory(userId);
                data.FactoryRawMaterialSupplierList = GetFactoryRawMaterialSupplierList();
                //data.SupplierList = GetSupplierList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Ejemplo n.º 6
0
        public object GetInitData(int userID, out Library.DTO.Notification notification)
        {
            notification      = new Library.DTO.Notification();
            notification.Type = Library.DTO.NotificationType.Success;

            DTO.InitFormData data = new DTO.InitFormData();

            try
            {
                Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();

                data.SupportSeason  = supportFactory.GetSeason();
                data.SupportFactory = supportFactory.GetFactory(userID);

                using (var context = CreateContext())
                {
                    context.FactoryPlanningMng_function_AddFactoryPlanningData();
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }

            return(data);
        }
Ejemplo n.º 7
0
        public override object GetInitData(int userId, out Notification notification)
        {
            notification      = new Notification();
            notification.Type = NotificationType.Success;

            InitFormDTO data = new InitFormDTO();

            try
            {
                Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();
                data.Factories = supportFactory.GetFactory().ToList();

                using (CompanyBranchMngEntities context = CreateContext())
                {
                    data.Locations = dataConverter.DB2DTO_Location(context.CompanyBranchMng_Location_View.ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }

            return(data);
        }
Ejemplo n.º 8
0
        public object GetInitData(int userID, out Notification notification)
        {
            DTO.EditForm data = new EditForm()
            {
                Season = new List <Support.DTO.Season>(), Factory = new List <Support.DTO.Factory>()
            };
            notification = new Notification()
            {
                Type = NotificationType.Success
            };

            try
            {
                Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();

                data.Season  = supportFactory.GetSeason().ToList();
                data.Factory = supportFactory.GetFactory(userID).ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }

            return(data);
        }
Ejemplo n.º 9
0
        public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data = new DTO.FrameMaterialProfile();
            data.Data.FrameMaterialProfileFactories = new List <DTO.FrameMaterialProfileFactory>();
            data.Factories      = new List <Module.Support.DTO.Factory>();
            data.FrameMaterials = new List <Module.Support.DTO.FrameMaterial>();

            //try to get data
            try
            {
                if (id > 0)
                {
                    using (FrameMaterialProfileMngEntities context = CreateContext())
                    {
                        var profile = context.FrameMaterialProfileMng_FrameMaterialProfile_View.FirstOrDefault(o => o.FrameMaterialProfileID == id);
                        if (profile == null)
                        {
                            throw new Exception("Can not found the profile to edit");
                        }
                        data.Data = converter.DB2DTO_FrameMaterialProfile(profile);
                    }
                }
                data.Factories      = supportFactory.GetFactory().ToList();
                data.FrameMaterials = supportFactory.GetFrameMaterial().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Ejemplo n.º 10
0
        public DTO.EditFormData GetData(int userId, int id, out Library.DTO.Notification notification)
        {
            DTO.EditFormData editFormData = new DTO.EditFormData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            Module.Support.DAL.DataFactory   support_factory = new Support.DAL.DataFactory();
            Module.Framework.DAL.DataFactory fwFactory       = new Module.Framework.DAL.DataFactory();
            try
            {
                using (FactoryStockReceiptEntities context = CreateContext())
                {
                    //auto create production item
                    context.FactoryStockReceiptMng_function_CreateProductionItem();
                    if (id > 0)
                    {
                        FactoryStockReceiptMng_FactoryStockReceipt_View dbItem;
                        dbItem = context.FactoryStockReceiptMng_FactoryStockReceipt_View.FirstOrDefault(o => o.FactoryStockReceiptID == id);
                        //check permission on factory
                        if (fwFactory.CheckFactoryPermission(userId, dbItem.FactoryID.Value) == 0)
                        {
                            throw new Exception("You do not have access permission on this factory");
                        }
                        editFormData.Data = converter.DB2DTO_FactoryStockReceipt(dbItem);
                    }
                    else
                    {
                        editFormData.Data = new DTO.FactoryStockReceipt();
                        editFormData.Data.FactoryStockReceiptDetails = new List <DTO.FactoryStockReceiptDetail>();
                    }
                    editFormData.Factories = support_factory.GetFactory(userId);

                    return(editFormData);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(editFormData);
            }
        }
Ejemplo n.º 11
0
        public DTO.PriceComparison.FormData GetItemToCompareData(int id, int?offerSeasonDetailID, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.PriceComparison.FormData data = new DTO.PriceComparison.FormData();
            data.Data              = new DTO.PriceComparison.ProductOptionDetailDTO();
            data.Factories         = new List <Support.DTO.Factory>();
            data.QuotationStatuses = new List <Support.DTO.QuotationStatus>();
            try
            {
                using (ProductOverviewRptEntities context = CreateContext())
                {
                    if (offerSeasonDetailID.HasValue && offerSeasonDetailID.Value != 0)
                    {
                        ProductOverviewRpt_OfferSeasonDetail_View dbItem = context.ProductOverviewRpt_OfferSeasonDetail_View.FirstOrDefault(o => o.OfferSeasonDetailID == offerSeasonDetailID);
                        if (dbItem == null)
                        {
                            throw new Exception("Item not found!");
                        }
                        data.Data = AutoMapper.Mapper.Map <ProductOverviewRpt_OfferSeasonDetail_View, DTO.PriceComparison.ProductOptionDetailDTO>(dbItem);
                    }
                    else
                    {
                        ProductOverviewRpt_PriceComparison_ProductOptionDetail_View dbItem = context.ProductOverviewRpt_PriceComparison_ProductOptionDetail_View.FirstOrDefault(o => o.FactoryOrderDetailID == id);
                        if (dbItem == null)
                        {
                            throw new Exception("Item not found!");
                        }
                        data.Data = converter.DB2DTO_PriceComparison_ProductOptionDetail(dbItem);
                    }
                }

                data.Factories         = supportFactory.GetFactory().ToList();
                data.QuotationStatuses = supportFactory.GetQuotationStatus().ToList();
                return(data);
            }
            catch (Exception ex)
            {
                ex = Library.Helper.GetInnerException(ex);
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }
            return(null);
        }
Ejemplo n.º 12
0
        public DTO.InitDataDTO GetInitData(int userId, out Notification notification)
        {
            notification = new Notification()
            {
                Type = NotificationType.Success
            };
            var data = new DTO.InitDataDTO();

            data.Factories = new List <Support.DTO.Factory>();

            try
            {
                data.Factories = supportFactory.GetFactory().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Ejemplo n.º 13
0
        public object GetInitForm(int userID, out Library.DTO.Notification notification)
        {
            notification      = new Library.DTO.Notification();
            notification.Type = Library.DTO.NotificationType.Success;

            DTO.InitFormDTO data = new DTO.InitFormDTO();

            try
            {
                Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory();

                data.Seasons   = supportFactory.GetSeason().ToList();
                data.Factories = supportFactory.GetFactory().Where(s => s.FactoryID == 374043 || s.FactoryID == 374072).ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = Library.Helper.GetInnerException(ex).Message;
            }

            return(data);
        }
Ejemplo n.º 14
0
        //
        // CUSTOM FUNCTION
        //

        public DTO.SearchFilterData GetInitData(out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SearchFilterData data = new DTO.SearchFilterData();
            data.Seasons   = new List <Support.DTO.Season>();
            data.Factories = new List <Support.DTO.Factory>();

            //try to get data
            try
            {
                data.Seasons   = supportFactory.GetSeason().ToList();
                data.Factories = supportFactory.GetFactory().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Ejemplo n.º 15
0
        public override DTO.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.EditFormData data = new DTO.EditFormData();
            data.Data                   = new DTO.UserProfile();
            data.Data.Permissions       = new List <DTO.Permission>();
            data.Data.FactoryAccesses   = new List <DTO.FactoryAccess>();
            data.Data.EmployeeFactories = new List <DTO.EmployeeFactory>();

            data.InternalCompanies   = new List <Support.DTO.InternalCompany>();
            data.InternalDepartments = new List <Support.DTO.InternalDepartment>();
            data.Locations           = new List <Support.DTO.Location>();
            data.UserGroups          = new List <Support.DTO.UserGroup>();
            data.Managers            = new List <Support.DTO.Employee>();
            data.JobLevels           = new List <Support.DTO.JobLevel>();
            data.Factories           = new List <Support.DTO.Factory>();

            //try to get data
            try
            {
                using (User2MngEntities context = CreateContext())
                {
                    data.Data = converter.DB2DTO_UserProfile(context.User2Mng_UserProfile_View.FirstOrDefault(o => o.UserId == id));

                    data.Data.Permissions = converter.DB2DTO_UserGroupPermissionList(context.User2Mng_UserGroupPermission_View.Where(o => o.UserGroupID == data.Data.UserGroupID).ToList());
                    List <DTO.Permission> permissions = converter.DB2DTO_UserPermissionList(context.User2Mng_UserPermission_View.Where(o => o.UserID == id).ToList());
                    DTO.Permission        dtoTmpPermission;
                    foreach (DTO.Permission dtoPermission in permissions)
                    {
                        dtoTmpPermission = data.Data.Permissions.FirstOrDefault(o => o.ModuleID == dtoPermission.ModuleID);

                        if (dtoTmpPermission != null)
                        {
                            dtoTmpPermission.UserPermissionID = dtoPermission.UserPermissionID;

                            if (!dtoTmpPermission.CanCreate)
                            {
                                dtoTmpPermission.CanCreateEditable = true;
                            }
                            if (dtoPermission.CanCreate)
                            {
                                dtoTmpPermission.CanCreate = true;
                            }

                            if (!dtoTmpPermission.CanRead)
                            {
                                dtoTmpPermission.CanReadEditable = true;
                            }
                            if (dtoPermission.CanRead)
                            {
                                dtoTmpPermission.CanRead = true;
                            }

                            if (!dtoTmpPermission.CanUpdate)
                            {
                                dtoTmpPermission.CanUpdateEditable = true;
                            }
                            if (dtoPermission.CanUpdate)
                            {
                                dtoTmpPermission.CanUpdate = true;
                            }

                            if (!dtoTmpPermission.CanDelete)
                            {
                                dtoTmpPermission.CanDeleteEditable = true;
                            }
                            if (dtoPermission.CanDelete)
                            {
                                dtoTmpPermission.CanDelete = true;
                            }

                            if (!dtoTmpPermission.CanPrint)
                            {
                                dtoTmpPermission.CanPrintEditable = true;
                            }
                            if (dtoPermission.CanPrint)
                            {
                                dtoTmpPermission.CanPrint = true;
                            }

                            if (!dtoTmpPermission.CanApprove)
                            {
                                dtoTmpPermission.CanApproveEditable = true;
                            }
                            if (dtoPermission.CanApprove)
                            {
                                dtoTmpPermission.CanApprove = true;
                            }

                            if (!dtoTmpPermission.CanReset)
                            {
                                dtoTmpPermission.CanResetEditable = true;
                            }
                            if (dtoPermission.CanReset)
                            {
                                dtoTmpPermission.CanReset = true;
                            }
                        }
                        else
                        {
                            int moduleID = dtoPermission.ModuleID;//using to debug
                        }
                    }

                    data.Data.FactoryAccesses   = converter.DB2DTO_FactoryAccessList(context.User2Mng_FactoryAccess_View.Where(o => o.UserID == id).ToList());
                    data.Data.EmployeeFactories = converter.DB2DTO_EmployeeFactoryList(context.User2Mng_EmployeeFactory_View.Where(o => o.EmployeeID == data.Data.EmployeeID).ToList());
                }

                // decorate
                int index = 0;
                foreach (DTO.Permission dtoPermission in data.Data.Permissions.Where(o => o.ParentID == 0).OrderBy(o => o.DisplayOrder))
                {
                    dtoPermission.DisplayOrder = index;
                    index++;
                    foreach (DTO.Permission dtoSubPermission in data.Data.Permissions.Where(o => o.ParentID == dtoPermission.ModuleID).OrderBy(o => o.DisplayOrder))
                    {
                        dtoSubPermission.DisplayText  = "-----" + dtoSubPermission.DisplayText;
                        dtoSubPermission.DisplayOrder = index;
                        index++;
                    }
                }

                data.InternalCompanies   = supportFactory.GetInternalCompany().ToList();
                data.InternalDepartments = supportFactory.GetInternalDepartment().ToList();
                data.Locations           = supportFactory.GetLocation().ToList();
                data.UserGroups          = supportFactory.GetUserGroup().ToList();
                data.Managers            = supportFactory.GetEmployee().ToList();
                data.JobLevels           = supportFactory.GetJobLevel().ToList();
                data.Factories           = supportFactory.GetFactory().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Ejemplo n.º 16
0
        public DTO.SearchFormData GetDataWithFilter(int userId, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            DTO.SearchFormData searchFormData = new DTO.SearchFormData();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            totalRows = 0;

            string factoryUD         = string.Empty;
            string clientUD          = string.Empty;
            string proformaInvoiceNo = string.Empty;
            string lds         = string.Empty;
            string articleCode = string.Empty;
            string description = string.Empty;
            int?   factoryID   = null;

            if (filters.ContainsKey("factoryUD"))
            {
                factoryUD = filters["factoryUD"].ToString();
            }
            if (filters.ContainsKey("clientUD"))
            {
                clientUD = filters["clientUD"].ToString();
            }
            if (filters.ContainsKey("proformaInvoiceNo"))
            {
                proformaInvoiceNo = filters["proformaInvoiceNo"].ToString();
            }
            if (filters.ContainsKey("lds"))
            {
                lds = filters["lds"].ToString();
            }
            if (filters.ContainsKey("articleCode"))
            {
                articleCode = filters["articleCode"].ToString();
            }
            if (filters.ContainsKey("description"))
            {
                description = filters["description"].ToString();
            }
            if (filters.ContainsKey("factoryID") && filters["factoryID"] != null)
            {
                factoryID = Convert.ToInt32(filters["factoryID"]);
            }

            //if (filters.ContainsKey("factoryIDs") && filters["factoryIDs"] != null)
            //{
            //    //pare object to list string of factoryid
            //    List<string> fID = ((Newtonsoft.Json.Linq.JArray)filters["factoryIDs"]).ToObject<List<string>>();
            //    foreach (var item in fID)
            //    {
            //        factoryIDs += item + ",";
            //    }
            //}
            Module.Support.DAL.DataFactory sFactory = new Support.DAL.DataFactory();
            searchFormData.Factories = sFactory.GetFactory(userId);
            try
            {
                using (FactoryStockListReportEntities context = CreateContext())
                {
                    List <int?> listFactoryID = context.UserFactoryAccess.Where(o => o.UserID == userId && o.CanAccess.HasValue && o.CanAccess.Value).Select(s => s.FactoryID).ToList();
                    //get total
                    searchFormData.TotalStockQnt       = context.FactoryStockListReportMng_FactoryStockList_View.Where(x => listFactoryID.Contains(x.FactoryID)).Sum(o => (o.TotalStockQnt.HasValue ? o.TotalStockQnt.Value : 0));
                    searchFormData.TotalStockQntIn40HC = context.FactoryStockListReportMng_FactoryStockList_View.Where(x => listFactoryID.Contains(x.FactoryID)).Sum(o => (o.TotalStockQntIn40HC.HasValue ? o.TotalStockQntIn40HC.Value : 0));
                    searchFormData.TotalProducedQnt    = context.FactoryStockListReportMng_FactoryStockList_View.Where(x => listFactoryID.Contains(x.FactoryID)).Sum(o => (o.TotalProducedQnt.HasValue ? o.TotalProducedQnt.Value : 0));
                    searchFormData.TotalNotPackedQnt   = context.FactoryStockListReportMng_FactoryStockList_View.Where(x => listFactoryID.Contains(x.FactoryID)).Sum(o => (o.TotalNotPackedQnt.HasValue ? o.TotalNotPackedQnt.Value : 0));
                    searchFormData.TotalPackedQnt      = context.FactoryStockListReportMng_FactoryStockList_View.Where(x => listFactoryID.Contains(x.FactoryID)).Sum(o => (o.TotalPackedQnt.HasValue ? o.TotalPackedQnt.Value : 0));

                    //search
                    var result = context.FactoryStockListReportMng_function_GetFactoryStockList(orderBy, orderDirection, factoryUD, clientUD, proformaInvoiceNo, lds, articleCode, description, factoryID, userId);
                    searchFormData.Data = converter.DB2DTO_FactoryStockList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());

                    //get sub total
                    var sumData = context.FactoryStockListReportMng_function_GetFactoryStockList(orderBy, orderDirection, factoryUD, clientUD, proformaInvoiceNo, lds, articleCode, description, factoryID, userId).ToList();
                    totalRows = sumData.Count();
                    searchFormData.SubTotalStockQnt       = sumData.Sum(o => (o.TotalStockQnt.HasValue ? o.TotalStockQnt.Value : 0));
                    searchFormData.SubTotalStockQntIn40HC = sumData.Sum(o => (o.TotalStockQntIn40HC.HasValue ? o.TotalStockQntIn40HC.Value : 0));
                    searchFormData.SubTotalProducedQnt    = sumData.Sum(o => (o.TotalProducedQnt.HasValue ? o.TotalProducedQnt.Value : 0));
                    searchFormData.SubTotalNotPackedQnt   = sumData.Sum(o => (o.TotalNotPackedQnt.HasValue ? o.TotalNotPackedQnt.Value : 0));
                    searchFormData.SubTotalPackedQnt      = sumData.Sum(o => (o.TotalPackedQnt.HasValue ? o.TotalPackedQnt.Value : 0));
                }
                return(searchFormData);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(searchFormData);
            }
        }
Ejemplo n.º 17
0
        public DTO.SearchForm GetDataWithFilter(int userId, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            DTO.SearchForm searchForm = new DTO.SearchForm();
            searchForm.Factories = new List <Support.DTO.Factory>();
            notification         = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            totalRows = 0;
            try
            {
                string qcReportUD        = null;
                int?   factoryID         = null;
                string clientUD          = null;
                string articleCode       = null;
                string proformaInvoiceNo = null;
                string updatedDate       = null;

                if (filters.ContainsKey("QCReportUD") && !string.IsNullOrEmpty(filters["QCReportUD"].ToString()))
                {
                    qcReportUD = filters["QCReportUD"].ToString().Replace("'", "''");
                }

                if (filters.ContainsKey("FactoryID") && filters["FactoryID"] != null && !string.IsNullOrEmpty(filters["FactoryID"].ToString()))
                {
                    factoryID = Convert.ToInt32(filters["FactoryID"]);
                }

                if (filters.ContainsKey("ArticleCode") && !string.IsNullOrEmpty(filters["ArticleCode"].ToString()))
                {
                    articleCode = filters["ArticleCode"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("ProformaInvoiceNo") && !string.IsNullOrEmpty(filters["ProformaInvoiceNo"].ToString()))
                {
                    proformaInvoiceNo = filters["ProformaInvoiceNo"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("UpdatedDate") && !string.IsNullOrEmpty(filters["UpdatedDate"].ToString()))
                {
                    updatedDate = filters["UpdatedDate"].ToString().Replace("'", "''");
                }
                if (filters.ContainsKey("ClientUD") && !string.IsNullOrEmpty(filters["ClientUD"].ToString()))
                {
                    clientUD = filters["ClientUD"].ToString().Replace("'", "''");
                }

                //if (filters.ContainsKey("TestDate") && !string.IsNullOrEmpty(filters["TestDate"].ToString()))
                //{
                //    testDate = filters["TestDate"].ToString().Replace("'", "''");
                //}
                DateTime?valTestDate = updatedDate.ConvertStringToDateTime();

                using (QCReportEntities context = CreateContext())
                {
                    totalRows = context.QCReportMng_function_SearchQCReportMng(qcReportUD, factoryID, clientUD, articleCode, proformaInvoiceNo, valTestDate, orderBy, orderDirection).Count();
                    var result = context.QCReportMng_function_SearchQCReportMng(qcReportUD, factoryID, clientUD, articleCode, proformaInvoiceNo, valTestDate, orderBy, orderDirection);
                    searchForm.Data = converter.DB2DTO_SearchQCReport(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
                searchForm.Factories = supportFactory.GetFactory().ToList();
                return(searchForm);
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
                return(searchForm);
            }
        }
Ejemplo n.º 18
0
        public SearchFormData GetDataWithFilter(int userID, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Notification notification)
        {
            // Define.
            SearchFormData searchFormData = new SearchFormData
            {
                SearchData = new List <SampleProductLocationSearchResultData>(),
                Seasons    = new List <Support.DTO.Season>(),
                Locations  = new List <SupportFactoryLocationData>(),
                Factories  = new List <Support.DTO.Factory>(),
                Clients    = new List <Support.DTO.Client>(),
                Statuses   = new List <Support.DTO.SampleProductStatus>()
            };

            notification = new Notification
            {
                Type = NotificationType.Success
            };

            totalRows = 0;

            // Main.
            try
            {
                string season = null;
                string sampleProductItemUD = null;
                string articleDescription  = null;
                string factoryUD           = null;
                string locationUD          = null;
                string clientUD            = null;
                int?   quantity            = null;
                int?   statusID            = null;

                if (filters.ContainsKey("Season") && filters["Season"] != null && !string.IsNullOrEmpty(filters["Season"].ToString().Replace("'", "''")))
                {
                    season = filters["Season"].ToString().Trim();
                }

                if (filters.ContainsKey("Code") && filters["Code"] != null && !string.IsNullOrEmpty(filters["Code"].ToString().Replace("'", "''")))
                {
                    sampleProductItemUD = filters["Code"].ToString().Trim();
                }

                if (filters.ContainsKey("ArticleDescription") && filters["ArticleDescription"] != null && !string.IsNullOrEmpty(filters["ArticleDescription"].ToString().Replace("'", "''")))
                {
                    articleDescription = filters["ArticleDescription"].ToString().Trim();
                }

                if (filters.ContainsKey("Factory") && filters["Factory"] != null && !string.IsNullOrEmpty(filters["Factory"].ToString().Replace("'", "''")))
                {
                    factoryUD = filters["Factory"].ToString().Trim();
                }

                if (filters.ContainsKey("Location") && filters["Location"] != null && !string.IsNullOrEmpty(filters["Location"].ToString().Replace("'", "''")))
                {
                    locationUD = filters["Location"].ToString().Trim();
                }

                if (filters.ContainsKey("Client") && filters["Client"] != null && !string.IsNullOrEmpty(filters["Client"].ToString().Replace("'", "''")))
                {
                    clientUD = filters["Client"].ToString().Trim();
                }

                if (filters.ContainsKey("Quantity") && filters["Quantity"] != null && !string.IsNullOrEmpty(filters["Quantity"].ToString().Replace("'", "''")))
                {
                    quantity = Convert.ToInt32(filters["Quantity"].ToString().Trim());
                }

                if (filters.ContainsKey("Status") && filters["Status"] != null && !string.IsNullOrEmpty(filters["Status"].ToString().Replace("'", "''")))
                {
                    statusID = Convert.ToInt32(filters["Status"].ToString().Trim());
                }

                using (var context = CreateContext())
                {
                    totalRows = context.SampleProductLocationMng_function_SampleProductLocationSearchResult(season, sampleProductItemUD, articleDescription, factoryUD, locationUD, clientUD, quantity, statusID, userID, orderBy, orderDirection).Count();

                    var results = context.SampleProductLocationMng_function_SampleProductLocationSearchResult(season, sampleProductItemUD, articleDescription, factoryUD, locationUD, clientUD, quantity, statusID, userID, orderBy, orderDirection);
                    searchFormData.SearchData = converter.DB2DTO_SampleLocationSearch(results.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());

                    var factoryResult = context.SampleProductLocationMng_function_SupportFactoryLocation(userID.ToString());
                    searchFormData.Locations = converter.DB2DTO_SampleFactory(factoryResult.ToList());
                }

                searchFormData.Seasons   = supportFactory.GetSeason().ToList();
                searchFormData.Clients   = supportFactory.GetClient().ToList();
                searchFormData.Factories = supportFactory.GetFactory(userID).ToList();
                searchFormData.Statuses  = supportFactory.GetSampleProductStatus().ToList();
            }
            catch (Exception ex)
            {
                notification.Type    = NotificationType.Error;
                notification.Message = ex.Message;
                searchFormData       = null;
            }

            // Result.
            return(searchFormData);
        }
Ejemplo n.º 19
0
        public DTO.PurchasingCreditNoteSearchData GetPurchasingCreditNoteSearchResult2(int userId, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            totalRows = 0;

            DTO.PurchasingCreditNoteSearchData data = new DTO.PurchasingCreditNoteSearchData();
            data.Data        = new List <DTO.PurchasingCreditNote>();
            data.DataFactory = new List <Support.DTO.Factory>();
            Module.Support.DAL.DataFactory support_factory = new Support.DAL.DataFactory();

            string invoiceNo    = string.Empty;
            string blNo         = string.Empty;
            string supplierNM   = string.Empty;
            string creditNoteNo = string.Empty;
            int?   factoryID    = null;

            if (filters.ContainsKey("invoiceNo"))
            {
                invoiceNo = filters["invoiceNo"].ToString();
            }
            if (filters.ContainsKey("blNo"))
            {
                blNo = filters["blNo"].ToString();
            }
            if (filters.ContainsKey("supplierNM"))
            {
                supplierNM = filters["supplierNM"].ToString();
            }
            if (filters.ContainsKey("creditNoteNo"))
            {
                creditNoteNo = filters["creditNoteNo"].ToString();
            }
            if (filters.ContainsKey("factoryID") && filters["factoryID"] != null)
            {
                factoryID = Convert.ToInt32(filters["factoryID"].ToString());
            }

            try
            {
                using (PurchasingCreditNoteEntities context = CreateContext())
                {
                    totalRows = context.PurchasingCreditNoteMng_function_SearchPurchasingCreditNote(userId, orderBy, orderDirection, invoiceNo, blNo, supplierNM, creditNoteNo, factoryID).Count();
                    var result = context.PurchasingCreditNoteMng_function_SearchPurchasingCreditNote(userId, orderBy, orderDirection, invoiceNo, blNo, supplierNM, creditNoteNo, factoryID);

                    data.Data        = converter.DB2DTO_PurchasingCreditNoteSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                    data.DataFactory = support_factory.GetFactory(userId);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                notification.DetailMessage.Add(ex.Message);
                if (ex.GetBaseException() != null)
                {
                    notification.DetailMessage.Add(ex.GetBaseException().Message);
                }
            }

            return(data);
        }