Exemplo n.º 1
0
        public override DTO.FactoryPaymentMng.EditData GetData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.FactoryPaymentMng.EditData data = new DTO.FactoryPaymentMng.EditData();
            data.FactoryPayment = new DTO.FactoryPaymentMng.FactoryPayment();

            try
            {
                using (FactoryPaymentMngEntities context = CreateContext())
                {
                    if (id > 0)
                    {
                        data.FactoryPayment = converter.DB2DTO_FactoryPayment(context.FactoryPaymentMng_FactoryPayment_View.FirstOrDefault(o => o.FactoryPaymentID == id));
                    }
                    data.Seasons   = support_factory.GetSeason().ToList();
                    data.Factories = support_factory.GetFactory().ToList();
                    data.Suppliers = support_factory.GetSupplier().ToList();
                }
            }
            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);
        }
Exemplo n.º 2
0
        public override bool UpdateData(int id, ref DTO.FactoryPaymentMng.FactoryPayment dtoItem, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (FactoryPaymentMngEntities context = CreateContext())
                {
                    FactoryPayment dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new FactoryPayment();
                        context.FactoryPayment.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.FactoryPayment.FirstOrDefault(o => o.FactoryPaymentID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "FactoryPayment not found!";
                        return(false);
                    }
                    else
                    {
                        // check concurrency
                        if (dbItem.ConcurrencyFlag != null && !dbItem.ConcurrencyFlag.SequenceEqual(Convert.FromBase64String(dtoItem.ConcurrencyFlag_String)))
                        {
                            throw new Exception(DALBase.Helper.TEXT_CONCURRENCY_CONFLICT);
                        }

                        converter.DTO2BD_FactoryPayment(dtoItem, ref dbItem);
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.FactoryPaymentID, out notification).FactoryPayment;
                        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);
            }
        }
Exemplo n.º 3
0
        public override DTO.FactoryPaymentMng.SearchData 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.FactoryPaymentMng.SearchData data = new DTO.FactoryPaymentMng.SearchData();
            data.FactoryPayments = new List <DTO.FactoryPaymentMng.FactoryPaymentSearch>();

            data.Seasons   = support_factory.GetSeason().ToList();
            data.Factories = support_factory.GetFactory().ToList();
            data.Suppliers = support_factory.GetSupplier().ToList();

            string PaymentReceiptNo = string.Empty;
            string Season           = string.Empty;
            int    FactoryID        = 0;

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

            totalRows = 0;
            try
            {
                using (FactoryPaymentMngEntities context = CreateContext())
                {
                    totalRows = context.FactoryPaymentMng_function_Search(orderBy, orderDirection, PaymentReceiptNo, Season, FactoryID).Count();
                    var result = context.FactoryPaymentMng_function_Search(orderBy, orderDirection, PaymentReceiptNo, Season, FactoryID);
                    data.FactoryPayments = converter.DB2DTO_FactoryPaymentSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
            }
            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);
        }
Exemplo n.º 4
0
        public override bool DeleteData(int id, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success, Message = "Delete success"
            };
            try
            {
                using (FactoryPaymentMngEntities context = CreateContext())
                {
                    FactoryPayment dbItem = context.FactoryPayment.FirstOrDefault(o => o.FactoryPaymentID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "FactoryPayment not found!";
                        return(false);
                    }
                    else
                    {
                        context.FactoryPayment.Remove(dbItem);
                        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);
            }
        }