コード例 #1
0
 public override bool DeleteData(int id, out DTO.Framework.Notification notification)
 {
     notification = new DTO.Framework.Notification()
     {
         Type = DTO.Framework.NotificationType.Success
     };
     try
     {
         using (ClientPaymentMngEntities context = CreateContext())
         {
             ClientPayment dbItem = context.ClientPayment.FirstOrDefault(o => o.ClientPaymentID == id);
             if (dbItem == null)
             {
                 notification.Message = "payment not found!";
                 return(false);
             }
             else
             {
                 context.ClientPayment.Remove(dbItem);
                 context.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         notification.Type    = DTO.Framework.NotificationType.Error;
         notification.Message = ex.Message;
         if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
         {
             notification.DetailMessage.Add(ex.InnerException.Message);
         }
         return(false);
     }
 }
コード例 #2
0
        public override bool DeleteData(int id, out DTO.Framework.Notification notification)
        {
            notification = new DTO.Framework.Notification()
            {
                Type = DTO.Framework.NotificationType.Success
            };

            try
            {
                using (MaterialMngEntities context = CreateContext())
                {
                    Material dbItem = context.Material.FirstOrDefault(o => o.MaterialID == id);
                    if (dbItem == null)
                    {
                        notification.Message = "Material not found!";
                        return(false);
                    }
                    else
                    {
                        context.Material.Remove(dbItem);
                        context.SaveChanges();

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = DTO.Framework.NotificationType.Error;
                notification.Message = ex.Message;
                return(false);
            }
        }
コード例 #3
0
        public override DTO.MaterialMng.EditFormData GetData(int id, out DTO.Framework.Notification notification)
        {
            notification = new DTO.Framework.Notification()
            {
                Type = DTO.Framework.NotificationType.Success
            };
            DTO.MaterialMng.EditFormData data = new DTO.MaterialMng.EditFormData();
            data.Data = new DTO.MaterialMng.Material();

            //try to get data
            try
            {
                using (MaterialMngEntities context = CreateContext())
                {
                    data.Data = converter.DB2DTO_Material(context.MaterialMng_Material_View.FirstOrDefault(o => o.MaterialID == id));
                }
            }
            catch (Exception ex)
            {
                notification.Type    = DTO.Framework.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
コード例 #4
0
        public override IEnumerable <DTO.ClientPaymentMng.ClientPaymentSearch> GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out DTO.Framework.Notification notification)
        {
            notification = new DTO.Framework.Notification()
            {
                Type = DTO.Framework.NotificationType.Success
            };
            totalRows = 0;

            string Season            = string.Empty;
            string ProformaInvoiceNo = string.Empty;
            string ClientUD          = string.Empty;
            string ClientNM          = string.Empty;
            int    SaleID            = 0;

            if (filters.ContainsKey("Season"))
            {
                Season = filters["Season"].ToString();
            }
            if (filters.ContainsKey("ProformaInvoiceNo"))
            {
                ProformaInvoiceNo = filters["ProformaInvoiceNo"].ToString();
            }
            if (filters.ContainsKey("ClientUD"))
            {
                ClientUD = filters["ClientUD"].ToString();
            }
            if (filters.ContainsKey("ClientNM"))
            {
                ClientNM = filters["ClientNM"].ToString();
            }
            if (filters.ContainsKey("SaleID") && filters["SaleID"] != null)
            {
                SaleID = Convert.ToInt32(filters["SaleID"].ToString());
            }


            //try to get data
            try
            {
                using (ClientPaymentMngEntities context = CreateContext())
                {
                    totalRows = context.ClientPaymentMng_function_SearchClientPayment(orderBy, orderDirection, Season, ProformaInvoiceNo, ClientUD, ClientNM, SaleID).Count();
                    var result = context.ClientPaymentMng_function_SearchClientPayment(orderBy, orderDirection, Season, ProformaInvoiceNo, ClientUD, ClientNM, SaleID);
                    return(converter.DB2DTO_ClientPaymentSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()));
                }
            }
            catch (Exception ex)
            {
                notification.Type    = DTO.Framework.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(new List <DTO.ClientPaymentMng.ClientPaymentSearch>());
            }
        }
コード例 #5
0
        public override bool UpdateData(int id, ref DTO.ClientPaymentMng.ClientPayment dtoItem, out DTO.Framework.Notification notification)
        {
            notification = new DTO.Framework.Notification()
            {
                Type = DTO.Framework.NotificationType.Success
            };
            try
            {
                using (ClientPaymentMngEntities context = CreateContext())
                {
                    ClientPayment dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new ClientPayment();
                        context.ClientPayment.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.ClientPayment.FirstOrDefault(o => o.ClientPaymentID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "payment 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);
                        }

                        //convert dto to db
                        converter.DTO2DB_ClientPayment(dtoItem, ref dbItem);
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.ClientPaymentID, out notification);
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = DTO.Framework.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(false);
            }
        }
コード例 #6
0
        public override DTO.MaterialMng.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out DTO.Framework.Notification notification)
        {
            notification = new DTO.Framework.Notification()
            {
                Type = DTO.Framework.NotificationType.Success
            };
            DTO.MaterialMng.SearchFormData data = new DTO.MaterialMng.SearchFormData();
            data.Data = new List <DTO.MaterialMng.MaterialSearchResult>();
            totalRows = 0;

            string MaterialUD = null;
            string MaterialNM = null;

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


            //try to get data
            try
            {
                using (MaterialMngEntities context = CreateContext())
                {
                    totalRows = context.MaterialMng_function_SearchMaterial(MaterialUD, MaterialNM, orderBy, orderDirection).Count();
                    var result = context.MaterialMng_function_SearchMaterial(MaterialUD, MaterialNM, orderBy, orderDirection);
                    data.Data = converter.DB2DTO_MaterialSearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());
                }
            }
            catch (Exception ex)
            {
                notification.Type    = DTO.Framework.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
コード例 #7
0
        public override DTO.ClientPaymentMng.ClientPayment GetData(int id, out DTO.Framework.Notification notification)
        {
            notification = new DTO.Framework.Notification()
            {
                Type = DTO.Framework.NotificationType.Success
            };
            //try to get data
            try
            {
                using (ClientPaymentMngEntities context = CreateContext())
                {
                    DTO.ClientPaymentMng.ClientPayment dtoItem = new DTO.ClientPaymentMng.ClientPayment();

                    if (id > 0)
                    {
                        ClientPaymentMng_ClientPayment_View dbItem;
                        dbItem = context.ClientPaymentMng_ClientPayment_View
                                 .Include("ClientPaymentMng_ClientPaymentDetail_View")
                                 .FirstOrDefault(o => o.ClientPaymentID == id);

                        dtoItem = converter.DB2DTO_ClientPayment(dbItem);
                    }
                    else
                    {
                        dtoItem.ClientPaymentDetails = new List <DTO.ClientPaymentMng.ClientPaymentDetail>();
                    }
                    return(dtoItem);
                }
            }
            catch (Exception ex)
            {
                notification.Type    = DTO.Framework.NotificationType.Error;
                notification.Message = ex.Message;
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message))
                {
                    notification.DetailMessage.Add(ex.InnerException.Message);
                }
                return(new DTO.ClientPaymentMng.ClientPayment());
            }
        }
コード例 #8
0
 public override bool Reset(int id, ref DTO.MaterialMng.Material dtoItem, out DTO.Framework.Notification notification)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
        public override bool UpdateData(int id, ref DTO.MaterialMng.Material dtoItem, out DTO.Framework.Notification notification)
        {
            notification = new DTO.Framework.Notification()
            {
                Type = DTO.Framework.NotificationType.Success
            };
            int    number;
            string indexName;

            try
            {
                using (MaterialMngEntities context = CreateContext())
                {
                    Material dbItem = null;
                    if (id == 0)
                    {
                        dbItem = new Material();
                        context.Material.Add(dbItem);
                    }
                    else
                    {
                        dbItem = context.Material.FirstOrDefault(o => o.MaterialID == id);
                    }

                    if (dbItem == null)
                    {
                        notification.Message = "Material not found!";
                        return(false);
                    }
                    else
                    {
                        converter.DTO2BD_Material(dtoItem, ref dbItem);
                        context.SaveChanges();

                        dtoItem = GetData(dbItem.MaterialID, out notification).Data;

                        return(true);
                    }
                }
            }
            catch (System.Data.DataException dEx)
            {
                notification.Type = DTO.Framework.NotificationType.Error;
                Library.ErrorHelper.DataExceptionParser(dEx, out number, out indexName);
                if (number == 2601 && !string.IsNullOrEmpty(indexName))
                {
                    if (indexName == "MaterialUDUnique")
                    {
                        notification.Message = "The Material Code is already exists";
                    }
                }
                else
                {
                    notification.Message = dEx.Message;
                }

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