private void UpdateReceiptPaymentRow(ReceiptPaymentItem receiptPayment)
        {
            int rowIndex = -1;
            int colIndex = -1;

            if (dgvReceiptFromCustomer.SelectedCells.Count > 0)
            {
                rowIndex = dgvReceiptFromCustomer.SelectedCells[0].RowIndex;
                colIndex = dgvReceiptFromCustomer.SelectedCells[0].ColumnIndex;
                receiptPayment.ReceiptPaymentID = applicationFacade.InsertUpdateTempReceiptPayment(receiptPayment);

                dgvReceiptFromCustomer.Rows[rowIndex].Cells["ReceiptPaymentID"].Value          = receiptPayment.ReceiptPaymentID;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["LedgerTypeCode"].Value            = receiptPayment.LedgerTypeCode;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["LedgerTypeName"].Value            = receiptPayment.LedgerTypeName;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["PaymentMode"].Value               = receiptPayment.PaymentMode;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["ChequeNumber"].Value              = receiptPayment.ChequeNumber;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["BankAccountLedgerTypeName"].Value = receiptPayment.BankAccountLedgerTypeName;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["BankAccountLedgerTypeCode"].Value = receiptPayment.BankAccountLedgerTypeCode;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["ChequeDate"].Value          = receiptPayment.ChequeDate == null ? String.Empty : ExtensionMethods.ConvertToAppDateFormat((DateTime)receiptPayment.ChequeDate);
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["Amount"].Value              = receiptPayment.Amount;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["ConsumedAmount"].Value      = receiptPayment.Amount - receiptPayment.UnadjustedAmount;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["UnadjustedAmount"].Value    = receiptPayment.UnadjustedAmount;
                dgvReceiptFromCustomer.Rows[rowIndex].Cells["OldReceiptPaymentID"].Value = receiptPayment.OldReceiptPaymentID;
            }
        }
示例#2
0
        public ActionResult AjaxForm()
        {
            var model = new ReceiptPaymentItem();

            if (DoAction == ActionType.Edit)
            {
                model = _da.GetReceiptPaymentItem(ArrId.FirstOrDefault());
            }
            ViewBag.CostType = _costTypeda.GetList(1, (int)Vouchers.ReceiptPayment);
            ViewBag.Action   = DoAction;
            return(View(model));
        }
示例#3
0
 private void DgvTransactions_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyData == Keys.Enter && dgvTransactions.Rows.Count > 0 && dgvTransactions.SelectedRows.Count > 0)
         {
             SelectedTransaction = dgvTransactions.SelectedRows[0].DataBoundItem as ReceiptPaymentItem;
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public ActionResult AjaxForm()
        {
            var model = new ReceiptPaymentItem();

            if (DoAction == ActionType.Edit)
            {
                model = _api.GetReceiptItem(ArrId.FirstOrDefault());
            }
            ViewBag.CostType   = _costTypeApi.GetList(UserItem.AgencyID, (int)Vouchers.Receipt);
            ViewBag.Action     = DoAction;
            ViewBag.AgencyId   = UserItem.AgencyID;
            ViewBag.UserCreate = UserItem.UserId;
            ViewBag.User       = _userApi.GetListAllAgency(UserItem.AgencyID);
            return(View(model));
        }
        private void FrmTrans_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                dgvReceiptFromCustomer.SelectionChanged -= DgvReceiptFromCustomer_SelectionChanged;

                ReceiptPaymentItem transaction = (sender as frmTransactions).SelectedTransaction;
                if (transaction != null && transaction.ReceiptPaymentID > 0)
                {
                    AddNewRowToGrid();


                    ReceiptPaymentItem transactionDetail = applicationFacade.GetTransactionByTransactionID(transaction.ReceiptPaymentID);
                    UpdateReceiptPaymentRow(transactionDetail);
                    DisplayDataGrid();

                    TransactionEntity transactionEntity = new TransactionEntity();

                    txtTransactAccount.Tag  = Convert.ToString(dgvReceiptFromCustomer.Rows[0].Cells["BankAccountLedgerTypeCode"].Value);
                    txtTransactAccount.Text = Convert.ToString(dgvReceiptFromCustomer.Rows[0].Cells["BankAccountLedgerTypeName"].Value);

                    transactionEntity.ReceiptPaymentID = (long)dgvReceiptFromCustomer.Rows[0].Cells["OldReceiptPaymentID"].Value;
                    transactionEntity.EntityType       = Constants.LedgerType.CustomerLedger;
                    transactionEntity.EntityCode       = Convert.ToString(dgvReceiptFromCustomer.Rows[0].Cells["LedgerTypeCode"].Value);

                    LoadGridBillOutstanding(transactionEntity);

                    transactionEntity.ReceiptPaymentID = (long)dgvReceiptFromCustomer.Rows[0].Cells["ReceiptPaymentID"].Value;
                    LoadGridBillAdjusted(transactionEntity);

                    dgvReceiptFromCustomer.SelectionChanged += DgvReceiptFromCustomer_SelectionChanged;

                    dgvReceiptFromCustomer.CurrentCell = dgvReceiptFromCustomer.Rows[0].Cells["LedgerTypeCode"];
                    dgvReceiptFromCustomer.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void FormCustomerLedgerMaster_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                ExtensionMethods.RemoveChildFormToPanel(this, (Control)sender, ExtensionMethods.MainPanel);
                CustomerLedgerMaster selectedCustomer = (sender as frmCustomerLedgerMaster).LastSelectedCustomerLedger;
                if (selectedCustomer != null)
                {
                    ReceiptPaymentItem receiptPaymentForSelectedCust = new ReceiptPaymentItem()
                    {
                        VoucherTypeCode           = Constants.VoucherTypeCode.RECEIPTFROMCUSTOMER,
                        VoucherDate               = ExtensionMethods.ConvertToSystemDateFormat(dtReceiptPayment.Text),
                        LedgerType                = Constants.LedgerType.CustomerLedger,
                        LedgerTypeCode            = selectedCustomer.CustomerLedgerCode,
                        LedgerTypeName            = selectedCustomer.CustomerLedgerName,
                        PaymentMode               = Constants.PaymentMode.CASH,
                        BankAccountLedgerTypeCode = Convert.ToString(txtTransactAccount.Tag),
                        BankAccountLedgerTypeName = Convert.ToString(txtTransactAccount.Text),
                        ChequeDate                = DateTime.Now
                    };

                    TransactionEntity transactionEntity = new TransactionEntity()
                    {
                        EntityType = Constants.LedgerType.CustomerLedger,
                        EntityCode = selectedCustomer.CustomerLedgerCode
                    };

                    UpdateReceiptPaymentRow(receiptPaymentForSelectedCust);
                    LoadGridBillOutstanding(transactionEntity);

                    dgvReceiptFromCustomer.Focus();
                    dgvReceiptFromCustomer.CurrentCell = dgvReceiptFromCustomer.Rows[dgvReceiptFromCustomer.SelectedCells[0].RowIndex].Cells["ChequeNumber"];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private ReceiptPaymentItem FillDataboundToCurrentRow()
        {
            ReceiptPaymentItem receiptPaymentItem = new ReceiptPaymentItem();

            if (dgvReceiptFromCustomer.SelectedCells.Count > 0)
            {
                int rowIndex = dgvReceiptFromCustomer.SelectedCells[0].RowIndex;
                receiptPaymentItem.ReceiptPaymentID          = (long)dgvReceiptFromCustomer.Rows[rowIndex].Cells["ReceiptPaymentID"].Value;
                receiptPaymentItem.VoucherNumber             = Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["VoucherNumber"].Value);
                receiptPaymentItem.VoucherTypeCode           = Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["VoucherTypeCode"].Value);
                receiptPaymentItem.VoucherDate               = Convert.ToDateTime(dgvReceiptFromCustomer.Rows[rowIndex].Cells["VoucherDate"].Value);
                receiptPaymentItem.LedgerType                = Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["LedgerType"].Value);
                receiptPaymentItem.LedgerTypeCode            = Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["LedgerTypeCode"].Value);
                receiptPaymentItem.PaymentMode               = Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["PaymentMode"].Value);
                receiptPaymentItem.Amount                    = ExtensionMethods.SafeConversionDecimal(Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["Amount"].Value));
                receiptPaymentItem.ChequeNumber              = Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["ChequeNumber"].Value);
                receiptPaymentItem.BankAccountLedgerTypeCode = Convert.ToString(txtTransactAccount.Tag);
                receiptPaymentItem.BankAccountLedgerTypeName = Convert.ToString(txtTransactAccount.Text);
                receiptPaymentItem.ChequeDate                = ExtensionMethods.ConvertToSystemDateFormat(dtReceiptPayment.Text);
                receiptPaymentItem.UnadjustedAmount          = ExtensionMethods.SafeConversionDecimal(Convert.ToString(dgvReceiptFromCustomer.Rows[rowIndex].Cells["UnadjustedAmount"].Value));
            }
            return(receiptPaymentItem);
        }
示例#8
0
        public PharmaBusinessObjects.Transaction.ReceiptPayment.ReceiptPaymentItem GetTransactionByTransactionID(long transactionID)
        {
            try
            {
                using (PharmaDBEntities context = new PharmaDBEntities())
                {
                    using (var transactionScope = context.Database.BeginTransaction())
                    {
                        try
                        {
                            var transaction = context.ReceiptPayment.Where(x => x.ReceiptPaymentID == transactionID).Select(x => x).FirstOrDefault();
                            var billAdjustmentListForTransaction = context.BillOutStandingsAudjustment.Where(x => x.ReceiptPaymentID == transaction.ReceiptPaymentID).Select(x => x).ToList();

                            var transactionObject = new ReceiptPaymentItem()
                            {
                                ReceiptPaymentID          = transaction.ReceiptPaymentID,
                                VoucherNumber             = transaction.VoucherNumber,
                                VoucherTypeCode           = transaction.VoucherTypeCode,
                                VoucherDate               = transaction.VoucherDate,
                                LedgerType                = transaction.LedgerType,
                                LedgerTypeCode            = transaction.LedgerTypeCode,
                                LedgerTypeName            = transaction.LedgerTypeName,
                                PaymentMode               = transaction.PaymentMode,
                                Amount                    = transaction.Amount,
                                UnadjustedAmount          = transaction.UnadjustedAmount,
                                BankAccountLedgerTypeCode = transaction.BankAccountLedgerTypeCode,
                                BankAccountLedgerTypeName = transaction.BankAccountLedgerTypeName,
                                ChequeDate                = transaction.ChequeDate,
                                ChequeClearDate           = transaction.ChequeClearDate,
                                IsChequeCleared           = transaction.IsChequeCleared,
                                POST         = transaction.POST,
                                PISNumber    = transaction.PISNumber,
                                ChequeNumber = transaction.ChequeNumber
                            };

                            ///Add record to temp receipt
                            ///
                            var copiedReceiptPayment = new Entity.TempReceiptPayment()
                            {
                                ReceiptPaymentID          = transaction.ReceiptPaymentID,
                                VoucherNumber             = transaction.VoucherNumber,
                                VoucherTypeCode           = transaction.VoucherTypeCode,
                                VoucherDate               = transaction.VoucherDate,
                                LedgerType                = transaction.LedgerType,
                                LedgerTypeCode            = transaction.LedgerTypeCode,
                                LedgerTypeName            = transaction.LedgerTypeName,
                                PaymentMode               = transaction.PaymentMode,
                                Ammount                   = transaction.Amount,
                                UnadjustedAmount          = transaction.UnadjustedAmount,
                                BankAccountLedgerTypeCode = transaction.BankAccountLedgerTypeCode,
                                BankAccountLedgerTypeName = transaction.BankAccountLedgerTypeName,
                                ChequeDate                = transaction.ChequeDate,
                                ChequeClearDate           = transaction.ChequeClearDate,
                                IsChequeCleared           = transaction.IsChequeCleared,
                                POST                = transaction.POST,
                                PISNumber           = transaction.PISNumber,
                                ChequeNumber        = transaction.ChequeNumber,
                                CreatedBy           = LoggedInUser.Username,
                                CreatedOn           = DateTime.Now,
                                OldReceiptPaymentID = transaction.ReceiptPaymentID
                            };

                            context.TempReceiptPayment.Add(copiedReceiptPayment);

                            ///Copy All previous bill adjustment
                            ///
                            foreach (BillOutStandingsAudjustment billOutStandingsAudjustment in billAdjustmentListForTransaction)
                            {
                                context.TempBillOutStandingsAudjustment.Add(new TempBillOutStandingsAudjustment()
                                {
                                    BillOutStandingsAudjustmentID = billOutStandingsAudjustment.BillOutStandingsAudjustmentID,
                                    PurchaseSaleBookHeaderID      = billOutStandingsAudjustment.PurchaseSaleBookHeaderID,
                                    VoucherNumber             = billOutStandingsAudjustment.VoucherNumber,
                                    VoucherTypeCode           = billOutStandingsAudjustment.VoucherTypeCode,
                                    VoucherDate               = billOutStandingsAudjustment.VoucherDate,
                                    ReceiptPaymentID          = billOutStandingsAudjustment.ReceiptPaymentID,
                                    BillOutStandingsID        = billOutStandingsAudjustment.BillOutStandingsID,
                                    AdjustmentVoucherNumber   = billOutStandingsAudjustment.AdjustmentVoucherNumber,
                                    AdjustmentVoucherTypeCode = billOutStandingsAudjustment.AdjustmentVoucherTypeCode,
                                    AdjustmentVoucherDate     = billOutStandingsAudjustment.AdjustmentVoucherDate,
                                    LedgerType     = billOutStandingsAudjustment.LedgerType,
                                    LedgerTypeCode = billOutStandingsAudjustment.LedgerTypeCode,
                                    Amount         = billOutStandingsAudjustment.Amount,
                                    ChequeNumber   = billOutStandingsAudjustment.ChequeNumber,
                                    OldBillOutStandingsAudjustmentID = billOutStandingsAudjustment.BillOutStandingsAudjustmentID,
                                    CreatedBy = LoggedInUser.Username,
                                    CreatedOn = DateTime.Now,
                                });
                            }

                            context.SaveChanges();
                            transactionScope.Commit();

                            transactionObject.ReceiptPaymentID    = (long)copiedReceiptPayment.ReceiptPaymentID;
                            transactionObject.OldReceiptPaymentID = (long)copiedReceiptPayment.OldReceiptPaymentID;

                            return(transactionObject);
                        }
                        catch (DbEntityValidationException dex)
                        {
                            transactionScope.Rollback();
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }