protected void gridviewReceiptVoucherAllocation_InitNewRowWithDefaultDataEvent(Controls.GridViewVoucherAllocation.GridViewVoucherAllocation.TransactionInitRowData data)
        {
            if (VoucherId != null && !VoucherId.Equals(Guid.Empty))
            {
                data.IssuedDate  = txtIssueDate.Date;
                data.Description = txtDescription.Text;

                ReceiptVouches voucher  = session.GetObjectByKey <ReceiptVouches>(VoucherId);
                int            sequence = 0;
                sequence =
                    voucher.ReceiptVouchesTransactions.Count(r => r.RowStatus == Constant.ROWSTATUS_ACTIVE) + 1;
                data.Code = String.Format("{0}_{1}", txtCode.Text, sequence);

                double amount = 0;
                if (voucher.SumOfDebit != 0)
                {
                    amount = voucher.SumOfCredit - voucher.ReceiptVouchesTransactions.Sum(r => r.Amount);
                    if (amount < 0)
                    {
                        amount = 0;
                    }
                }
                else
                {
                    amount = (double)spinAmount.Number - voucher.ReceiptVouchesTransactions.Sum(r => r.Amount);
                    if (amount < 0)
                    {
                        amount = 0;
                    }
                }
                data.Amount = amount;
            }
        }
 private ReceiptVouches GetCurrentReceiptVoucher()
 {
     if (VoucherId.Equals(Guid.Empty))
     {
         throw new Exception("Invalid key");
     }
     return(session.GetObjectByKey <ReceiptVouches>(VoucherId));
 }
 private NAS.DAL.Vouches.Vouches GetCurrentVoucher(Session _session)
 {
     if (VoucherId.Equals(Guid.Empty))
     {
         return(null);
     }
     return(_session.GetObjectByKey <NAS.DAL.Vouches.Vouches>(VoucherId));
 }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GenerateViewStateControlId();
                cpVoucherBookingEntry.ClientInstanceName = string.Format("cpVoucherBookingEntry{0}", ViewStateControlId);
                ldpnCostingEditForm.ClientInstanceName   = string.Format("ldpnCostingEditForm{0}", ViewStateControlId);
                GUIContext = new NAS.GUI.Pattern.Context();
            }

            dsOriginArtifact.CriteriaParameters["VoucherId"].DefaultValue    = VoucherId.ToString();
            dsVoucherAllocation.CriteriaParameters["VoucherId"].DefaultValue = VoucherId.ToString();
        }
 private void UpdateState()
 {
     if (!VoucherId.Equals(Guid.Empty))
     {
         if (Strategy.VoucherTransactionBO.IsVoucherLockedBookingEntry(VoucherId))
         {
             GUIContext.State = new VoucherLockedBookingdEntries(this);
         }
         else if (Strategy.VoucherTransactionBO.CanBookEntries(VoucherId))
         {
             GUIContext.State = new VoucherCanBookingEntries(this);
         }
         else
         {
             GUIContext.State = new VoucherCanNotBookingEntries(this);
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         GenerateViewStateControlId();
         GUIContext = new Context();
         VoucherId  = Guid.Empty;
         BillId     = Guid.Empty;
         hiddenField["voucherId"] = null;
     }
     if (!VoucherId.Equals(Guid.Empty))
     {
         InitGridViewVoucherAllocation();
         InitVoucherBookingEntriesForm();
     }
     hiddenField["voucherId"] = VoucherId;
     //UpdateBookingEntryState();
     gridviewReceiptVoucherAllocation.InitNewRowWithDefaultDataEvent += new Voucher.Controls.GridViewVoucherAllocation.GridViewVoucherAllocation.InitNewRowWithDefaultDataHandler(gridviewReceiptVoucherAllocation_InitNewRowWithDefaultDataEvent);
 }
        protected void gridVoucherAllocation_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            try
            {
                using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                {
                    if (VoucherId == null || VoucherId.Equals(Guid.Empty))
                    {
                        throw new Exception("The operation is not supported. Please set VoucherId for the gridview.");
                    }
                    //Code
                    //
                    e.NewValues["VouchesId!Key"] = VoucherId;

                    ASPxCallbackPanel panel = (ASPxCallbackPanel)gridVoucherAllocation
                                              .FindEditRowCellTemplateControl(
                        gridVoucherAllocation.Columns["MasterAccountActor"] as GridViewDataColumn,
                        "cpnMasterAcountActor");

                    AccountActorComboBox accountActorComboBox =
                        (AccountActorComboBox)panel.FindControl("accountActorComboBox");

                    WebModule.Accounting.AllocationConfigure.Controls.AccountActor accountActor =
                        accountActorComboBox.GetSelectedItem();

                    uow.CommitChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                e.Cancel = true;
                gridVoucherAllocation.CancelEdit();
            }
        }