Example #1
0
        private void dgvTender_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewRow row = dgvTender.Rows[e.RowIndex];

                if (dgvTender.CurrentCell.RowIndex == 0 && dgvTender.CurrentCell.ColumnIndex == dgvTender.Columns["TenderButtons"].Index)
                {
                }
                else if (dgvTender.CurrentCell.RowIndex > 0 && dgvTender.CurrentCell.ColumnIndex == dgvTender.Columns["TenderButtons"].Index)
                {
                    payType = new MstPayType
                    {
                        Id           = Convert.ToInt32(row.Cells[0].Value),
                        PayType      = row.Cells[1].Value.ToString(),
                        AccountId    = Convert.ToInt32(row.Cells[2].Value),
                        TenderAmount = Convert.ToDecimal(row.Cells[4].Value)
                    };

                    CollectionPayTypeInformationForm payTypeForm = new CollectionPayTypeInformationForm(this, payType);
                    payTypeForm.ShowDialog();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
            }
        }
Example #2
0
        private void dgvTender_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row          = dgvTender.Rows[e.RowIndex];
            decimal         tenderAmount = 0;

            if (dgvTender.CurrentCell.RowIndex == 0)
            {
                if (trnListCollectionLines.Count == 0)
                {
                    tenderAmount = Convert.ToDecimal(row.Cells[4].Value);

                    payType = new MstPayType
                    {
                        Id        = Convert.ToInt32(row.Cells[0].Value),
                        PayType   = row.Cells[1].Value.ToString(),
                        AccountId = Convert.ToInt32(row.Cells[2].Value)
                    };

                    collectionLine = new TrnCollectionLine
                    {
                        Amount    = tenderAmount,
                        PayTypeId = payType.Id,
                        AccountId = payType.AccountId
                    };

                    trnListCollectionLines.Add(collectionLine);
                }
                else
                {
                    var currentCash = trnListCollectionLines.Single(d => d.PayTypeId == 1);
                    trnListCollectionLines.Remove(currentCash);

                    tenderAmount = Convert.ToDecimal(row.Cells[4].Value);

                    payType = new MstPayType
                    {
                        Id        = Convert.ToInt32(row.Cells[0].Value),
                        PayType   = row.Cells[1].Value.ToString(),
                        AccountId = Convert.ToInt32(row.Cells[2].Value)
                    };

                    collectionLine = new TrnCollectionLine
                    {
                        Amount    = tenderAmount,
                        PayTypeId = payType.Id,
                        AccountId = payType.AccountId
                    };

                    trnListCollectionLines.Add(collectionLine);
                }
            }
            else
            {
                payType = new MstPayType
                {
                    Id           = Convert.ToInt32(row.Cells[0].Value),
                    PayType      = row.Cells[1].Value.ToString(),
                    AccountId    = Convert.ToInt32(row.Cells[2].Value),
                    TenderAmount = Convert.ToDecimal(row.Cells[4].Value)
                };

                CollectionPayTypeInformationForm payTypeForm = new CollectionPayTypeInformationForm(this, payType);
                payTypeForm.ShowDialog();
            }
            GetTenderTotalAmount();
        }