Пример #1
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();
            //Details
            editFormData.Data = new DTO.LabelingPackaging();
            editFormData.Data.LabelingPackagingDetails          = new List <DTO.LabelingPackagingDetail>();
            editFormData.Data.LabelingPackagingSparepartDetails = new List <DTO.LabelingPackagingSparepartDetail>();
            editFormData.Data.LabelingPackagingRemarks          = new List <DTO.LabelingPackagingRemark>();

            try
            {
                using (LPOverviewEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        LabelingPackagingMng_LabelingPackaging_View dbItem;
                        dbItem = context.LabelingPackagingMng_LabelingPackaging_View.FirstOrDefault(o => o.LabelingPackagingID == id);

                        //check permission on factory
                        int FactoryID = Convert.ToInt32(dbItem.FactoryID);
                        if (fwFactory.CheckFactoryPermission(userId, FactoryID) == 0)
                        {
                            throw new Exception("You do not have access permission on this factory");
                        }
                        editFormData.Data = converter.DB2DTO_LabelingPackaging(dbItem);
                    }
                    else
                    {
                        editFormData.Data = new DTO.LabelingPackaging();
                        editFormData.Data.LabelingPackagingDetails          = new List <DTO.LabelingPackagingDetail>();
                        editFormData.Data.LabelingPackagingSparepartDetails = new List <DTO.LabelingPackagingSparepartDetail>();
                        editFormData.Data.LabelingPackagingRemarks          = new List <DTO.LabelingPackagingRemark>();
                        editFormData.Data.LabelingPackagingOtherFiles       = new List <DTO.LabelingPackagingOtherFile>();
                    }
                    //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);
            }
        }
Пример #2
0
        public bool ReviseData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (LPOverviewEntities context = CreateContext())
                {
                    LabelingPackaging dbItem = context.LabelingPackaging.FirstOrDefault(o => o.LabelingPackagingID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "LP not found!";
                        return(false);
                    }
                    else
                    {
                        dbItem.LPStatusID = 1;
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            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(false);
            }
        }
Пример #3
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;

            int?   UserID            = userID;
            string Season            = null;
            int?   SaleID            = null;
            string ProformaInvoiceNo = null;
            string FactoryUD         = null;
            string ClientUD          = null;
            string ApprovedName      = null;


            if (filters.ContainsKey("Season") && !string.IsNullOrEmpty(filters["Season"].ToString()))
            {
                Season = filters["Season"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ProformaInvoiceNo") && !string.IsNullOrEmpty(filters["ProformaInvoiceNo"].ToString()))
            {
                ProformaInvoiceNo = filters["ProformaInvoiceNo"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ClientUD") && !string.IsNullOrEmpty(filters["ClientUD"].ToString()))
            {
                ClientUD = filters["ClientUD"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("FactoryUD") && !string.IsNullOrEmpty(filters["FactoryUD"].ToString()))
            {
                FactoryUD = filters["FactoryUD"].ToString().Replace("'", "''");
            }
            if (filters.ContainsKey("ApprovedName") && !string.IsNullOrEmpty(filters["ApprovedName"].ToString()))
            {
                ApprovedName = filters["ApprovedName"].ToString().Replace("'", "''");
            }

            try
            {
                using (LPOverviewEntities context = CreateContext())
                {
                    totalRows = context.LPOverview_function_SearchLabelingPackaging(orderBy, orderDirection, UserID, Season, SaleID, ProformaInvoiceNo, FactoryUD, ClientUD, ApprovedName).Count();
                    var result = context.LPOverview_function_SearchLabelingPackaging(orderBy, orderDirection, UserID, Season, SaleID, ProformaInvoiceNo, FactoryUD, ClientUD, ApprovedName);
                    searchFormData.Data = converter.DB2DTO_LPOverviewSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
                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);
            }
        }