示例#1
0
        public DTO.EditFormData GetEditData(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.DueColorDTO();

            //try to get data
            try
            {
                using (DueColorMngEntities context = CreateContext())
                {
                    data.Data = converter.DB2DTO_DueColor(context.DueColorMng_DueColor_View.FirstOrDefault(o => o.DueColorID == id));
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
示例#2
0
        public bool Delete(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DueColorMngEntities context = CreateContext())
                {
                    DueColor dbItem = context.DueColor.FirstOrDefault(o => o.DueColorID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "MaterialColor not found!";
                        return(false);
                    }
                    else
                    {
                        context.DueColor.Remove(dbItem);
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;

                return(false);
            }
        }
示例#3
0
        public DTO.SearchFormData GetDataWithFilters(System.Collections.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
            };
            DTO.SearchFormData data = new DTO.SearchFormData();
            data.Data = new List <DTO.DueColorSearchDTO>();
            totalRows = 0;

            string DueColorUD = null;
            string DueColorNM = null;

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

            //try to get data
            try
            {
                using (DueColorMngEntities context = CreateContext())
                {
                    totalRows = context.DueColorMng_function_SearchDueColor(DueColorNM, orderBy, orderDirection).Count();
                    var result = context.DueColorMng_function_SearchDueColor(DueColorNM, orderBy, orderDirection);
                    data.Data = converter.DB2DTO_DueColorSearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }