Example #1
0
 private void Load(PaymentChargeData data)
 {
     Init();
     if (data != null)
     {
         ChargeID         = data.charge_id;
         PaymentID        = data.payment_id;
         RequisitionID    = data.requisition_id;
         CompanyID        = data.company_id;
         FundID           = data.fund_id;
         DepartmentID     = data.department_id;
         AccountID        = data.account_id;
         FYStartDate      = data.fiscal_year_start;
         Amount           = data.amount;
         CreatedByUserID  = data.created_by;
         ModifiedByUserID = data.modified_by;
         DateCreated      = data.date_created;
         DateModified     = data.date_modified;
         Active           = data.active;
     }
 }
Example #2
0
        public void Save(string uid)
        {
            try
            {
                if (String.IsNullOrEmpty(uid))
                {
                    throw new ArgumentNullException("uid", "User ID is required.");
                }

                Dictionary <string, string> ValErrors = Validate();
                if (ValErrors.Count > 0)
                {
                    throw new RequisitionNotValidException("Payment Charge is not valid.", ValErrors);
                }

                using (PurchasingContext Context = ContextHelper.GetDBContext())
                {
                    Enums.HistoryType ChangeType;
                    PaymentCharge     Original = null;
                    PaymentChargeData Data     = null;

                    if (ChargeID == 0)
                    {
                        ChangeType = Enums.HistoryType.ADD;

                        Data              = new PaymentChargeData();
                        Data.created_by   = uid;
                        Data.date_created = DateTime.Now;
                    }
                    else
                    {
                        ChangeType = Enums.HistoryType.UPDATE;
                        Data       = Context.PaymentChargeDatas.FirstOrDefault(x => x.charge_id == ChargeID);
                        Original   = new PaymentCharge(Data);
                    }

                    Data.payment_id        = PaymentID;
                    Data.requisition_id    = RequisitionID;
                    Data.company_id        = CompanyID;
                    Data.fund_id           = FundID;
                    Data.department_id     = DepartmentID;
                    Data.account_id        = AccountID;
                    Data.project_id        = ProjectID;
                    Data.fiscal_year_start = FYStartDate;
                    Data.amount            = Amount;
                    Data.modified_by       = uid;
                    Data.date_modified     = DateTime.Now;
                    Data.active            = Active;

                    if (ChargeID == 0)
                    {
                        Context.PaymentChargeDatas.InsertOnSubmit(Data);
                    }

                    Context.SubmitChanges();
                    Load(Data);

                    SaveHistory(ChangeType, Original, uid);
                }
            }
            catch (Exception ex)
            {
                throw new RequisitionException("An error has occurred while saving payment charge.", ex);
            }
        }
Example #3
0
 public PaymentCharge(PaymentChargeData data)
 {
     Load(data);
 }