예제 #1
0
        internal APartyEntity Read(int id)
        {
            // check if supplier, if not get customer and return
            APartyEntity party = SupplierMapper.Read(id);

            if (party == null)
            {
                party = CustomerMapper.Read(id);
            }

            return(party);
        }
예제 #2
0
        protected override PaymentEntity entityFromReader(SqlDataReader reader)
        {
            //Reads the different columns from the database and set them to corresponding data type in the program.
            DateTime dueDate     = (DateTime)reader["DueDate"];
            decimal  dueAmount   = (decimal)reader["DueAmount"];
            DateTime paidDate    = (DateTime)reader["PaidDate"];
            decimal  paidAmount  = (decimal)reader["PaidAmount"];
            bool     paid        = (bool)reader["Paid"];
            bool     archived    = (bool)reader["Archived"];
            string   attachments = (string)reader["Attachments"];

            int         payerId = (int)reader["Payer"];
            int         payeeId = (int)reader["Payee"];
            string      note    = (string)reader["Note"];
            PaymentType type    = (PaymentType)Enum.Parse(typeof(PaymentType), reader["Type"].ToString());
            string      sale    = (string)reader["Sale"];
            int         booking = (int)reader["Booking"];
            string      invoice = (string)reader["Invoice"];

            int      id           = (int)reader["PaymentId"];
            DateTime lastModified = (DateTime)reader["LastModified"];
            bool     deleted      = (bool)reader["Deleted"];

            APartyEntity payer = PartyMapper.Read(payerId);
            APartyEntity payee = PartyMapper.Read(payeeId);

            PaymentEntity paymentEntity = new PaymentEntity(dueDate, dueAmount, payer,
                                                            payee, type, sale, booking);

            paymentEntity.PaidDate   = paidDate;
            paymentEntity.PaidAmount = paidAmount;
            paymentEntity.Paid       = paid;
            paymentEntity.Archived   = archived;
            if (attachments != "")
            {
                foreach (string attachment in attachments.Split(';'))
                {
                    paymentEntity.AddAttachment(attachment);
                }
            }

            paymentEntity.Note    = note;
            paymentEntity.Invoice = invoice;

            paymentEntity.Id           = id;
            paymentEntity.LastModified = lastModified;
            paymentEntity.Deleted      = deleted;

            return(paymentEntity);
        }