Example #1
0
        public override DTO.FrameMaterialMng.EditFormData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.FrameMaterialMng.EditFormData data = new DTO.FrameMaterialMng.EditFormData();
            data.Data = new DTO.FrameMaterialMng.FrameMaterial();

            //try to get data
            try
            {
                using (FrameMaterialMngEntities context = CreateContext())
                {
                    data.Data = converter.DB2DTO_FrameMaterial(context.FrameMaterialMng_FrameMaterial_View.FirstOrDefault(o => o.FrameMaterialID == id));
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
Example #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 (FrameMaterialMngEntities context = CreateContext())
                {
                    FrameMaterial dbItem = context.FrameMaterial.FirstOrDefault(o => o.FrameMaterialID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "Frame material not found!";
                        return(false);
                    }
                    else
                    {
                        context.FrameMaterial.Remove(dbItem);
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
                return(false);
            }
        }
Example #3
0
        public override DTO.FrameMaterialMng.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.FrameMaterialMng.SearchFormData data = new DTO.FrameMaterialMng.SearchFormData();
            data.Data = new List <DTO.FrameMaterialMng.FrameMaterialSearchResult>();
            totalRows = 0;

            string FrameMaterialUD = null;
            string FrameMaterialNM = null;

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

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

            return(data);
        }