예제 #1
0
        public static List <Data_Supplier> GetSuppliersWithPaymentStagingCheck(String username)
        {
            try {
                List <Data_Supplier> suppliers = null;

                using (NewcourtEntities ctx = new NewcourtEntities()) {
                    suppliers = (from a in ctx.Suppliers
                                 select new Data_Supplier()
                    {
                        SupplierID = a.SupplierID,
                        SupplierTypeCode = a.SupplierTypeCode,
                        FirstName = a.FirstName,
                        Surname = a.Surname,
                        Address1 = a.Address1,
                        Address2 = a.Address2,
                        Address3 = a.Address3,
                        Address4 = a.Address4,
                        Address5 = a.Address5,
                        Phone = a.Phone,
                        Mobile = a.Mobile,
                        PPSVat = a.PPSVat,
                        BankName = a.BankName,
                        BankAddress1 = a.BankAddress1,
                        BankAddress2 = a.BankAddress2,
                        BankAddress3 = a.BankAddress3,
                        BankAddress4 = a.BankAddress4,
                        BankAddress5 = a.BankAddress5,
                        BankAccNumber = a.BankAccNumber,
                        SortCode = a.SortCode,
                        BIC = a.BIC,
                        IBAN = a.IBAN,
                        SupplierTypeName = a.SupplierTypes.Name,
                        IsValidForPayment = true
                    }).ToList();

                    List <Data_PaymentStaging> payments = Data_PaymentStaging.GetPaymentStagingByUsername(username);

                    if (payments != null)
                    {
                        foreach (var i in suppliers)
                        {
                            if (payments.Exists(a => a.SuppplierId == i.SupplierID))
                            {
                                i.PaymentExists = true;
                            }

                            if (String.IsNullOrEmpty(i.BIC) || String.IsNullOrEmpty(i.IBAN))
                            {
                                i.IsValidForPayment = false;
                            }
                        }
                    }
                }

                return(suppliers);
            } catch (Exception ex) {
                throw ex;
            }
        }
예제 #2
0
        public static void SavePaymentStaging(Data_PaymentStaging payment)
        {
            try
            {
                using (NewcourtEntities ctx = new NewcourtEntities())
                {
                    PaymentStaging record = ctx.PaymentStaging.FirstOrDefault(a => a.Username == payment.Username && a.SupplierId == payment.SuppplierId);

                    if (record != null)
                    {
                        record.Amount = payment.Amount;
                        ctx.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public static List <Data_Supplier> SearchSuppliers(String username, String keyword, String supplierTypeCode, bool includeBank)
        {
            try {
                List <Data_Supplier> suppliers = null;

                using (NewcourtEntities ctx = new NewcourtEntities()) {
                    keyword   = String.Format("{0}", keyword);
                    suppliers = (from a in ctx.Suppliers
                                 where (keyword == String.Empty || a.FirstName.Contains(keyword) || a.Surname.Contains(keyword) || a.Address1.Contains(keyword) ||
                                        a.Address2.Contains(keyword) || a.Address3.Contains(keyword) || a.Address4.Contains(keyword) || a.Address5.Contains(keyword)) ||
                                 (includeBank && a.BIC.Contains(keyword)) || (includeBank && a.BIC.Contains(keyword))
                                 where (a.SupplierTypes.SupplierTypeCode == supplierTypeCode || supplierTypeCode == String.Empty)
                                 select new Data_Supplier()
                    {
                        SupplierID = a.SupplierID,
                        SupplierTypeCode = a.SupplierTypeCode,
                        FirstName = a.FirstName,
                        Surname = a.Surname,
                        Address1 = a.Address1,
                        Address2 = a.Address2,
                        Address3 = a.Address3,
                        Address4 = a.Address4,
                        Address5 = a.Address5,
                        Phone = a.Phone,
                        Mobile = a.Mobile,
                        PPSVat = a.PPSVat,
                        BankName = a.BankName,
                        BankAddress1 = a.BankAddress1,
                        BankAddress2 = a.BankAddress2,
                        BankAddress3 = a.BankAddress3,
                        BankAddress4 = a.BankAddress4,
                        BankAddress5 = a.BankAddress5,
                        BankAccNumber = a.BankAccNumber,
                        SortCode = a.SortCode,
                        BIC = a.BIC,
                        IBAN = a.IBAN,
                        SupplierTypeName = a.SupplierTypes.Name,
                        IsValidForPayment = true
                    }).ToList();

                    List <Data_PaymentStaging> payments = Data_PaymentStaging.GetPaymentStagingByUsername(username);

                    if (payments != null)
                    {
                        foreach (var i in suppliers)
                        {
                            if (payments.Exists(a => a.SuppplierId == i.SupplierID))
                            {
                                i.PaymentExists = true;
                            }

                            if (i.BIC.Trim() == String.Empty || i.IBAN.Trim() == String.Empty)
                            {
                                i.IsValidForPayment = false;
                            }
                        }
                    }

                    return(suppliers);
                }
            } catch (Exception ex) {
                throw ex;
            }
        }