コード例 #1
0
        public override DTO.FrameMaterialColorMng.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.FrameMaterialColorMng.EditFormData data = new DTO.FrameMaterialColorMng.EditFormData();
            data.Data = new DTO.FrameMaterialColorMng.FrameMaterialColor();

            //try to get data
            try
            {
                using (FrameMaterialColorMngEntities context = CreateContext())
                {
                    data.Data = converter.DB2DTO_FrameMaterialColor(context.FrameMaterialColorMng_FrameMaterialColor_View.FirstOrDefault(o => o.FrameMaterialColorID == id));
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
コード例 #2
0
        public override bool DeleteData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };

            try
            {
                using (FrameMaterialColorMngEntities context = CreateContext())
                {
                    FrameMaterialColor dbItem = context.FrameMaterialColor.FirstOrDefault(o => o.FrameMaterialColorID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "Frame material color not found!";
                        return(false);
                    }
                    else
                    {
                        context.FrameMaterialColor.Remove(dbItem);
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                return(false);
            }
        }
コード例 #3
0
        public override DTO.FrameMaterialColorMng.SearchFormData GetDataWithFilter(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.FrameMaterialColorMng.SearchFormData data = new DTO.FrameMaterialColorMng.SearchFormData();
            data.Data = new List <DTO.FrameMaterialColorMng.FrameMaterialColorSearchResult>();
            totalRows = 0;

            string FrameMaterialColorUD = null;
            string FrameMaterialColorNM = null;

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


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

            return(data);
        }