Hi all,
Passing information from one window to another window, with customerid, custname, original amount. These field will be in header of next window. And in next window datagrid fields are…checkbox, Amount remaing, apply amount.
Funcationality:
1) Suppose in header original amount is 7000.
In datagrid amount remaining is 500, and apply amount field 0. In this case when user select check box in datagrid amount remaining values 500 should go apply amount field of datagrid field. And this 500 amount should be deducted from the original amount (i.e 700-500=6500). And once total of apply amount field becomes 7000(which is equal to original amount). And after that if user try to select the check box, user will get message "you cant select". And once user uncheck the checkbox the apply amount values should be passed to remaining amount field and original amount values will be increased.
In my case values are passing from remaining amount to apply amount. But remaining amount field is not getting 0 and original amount field values are not reducing.
private void GrdViewApply_CellClick(object sender, DataGridViewCellEventArgs e)
{
decimal RemAmt;
decimal enteramt;
decimal OriginalAmt;
if (e.RowIndex > -1 && e.ColumnIndex > -1)
if (txtOriginalAmt.Text != string.Empty )
OriginalAmt = Convert.ToDecimal(txtOriginalAmt.Text);
}
if (e.ColumnIndex == 0)
bool value;
value = Convert.ToBoolean(GrdViewApply.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
if (value == true && GrdViewApply.Rows[e.RowIndex].Cells[3].Value != DBNull.Value)
//GrdViewApply.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = false;
enteramt = Convert.ToDecimal(GrdViewApply.Rows[e.RowIndex].Cells[3].Value);
RemAmt = Convert.ToDecimal(GrdViewApply.Rows[e.RowIndex].Cells[2].Value) + enteramt;
GrdViewApply.Rows[e.RowIndex].Cells[3].Value = DBNull.Value;
GrdViewApply.Rows[e.RowIndex].Cells[2].Value = RemAmt;
//decimal origamount =Convert.ToDecimal(txtOriginalAmt.Text);
//origamount = origamount -Convert.ToDecimal(DBNull.Value);
//txtOriginalAmt.Text = origamount.ToString();
txtOriginalAmt.Text = DBNull.Value.ToString();
//OriginalAmt = Convert.ToDecimal(DBNull.Value);
else
RemAmt = Convert.ToDecimal(GrdViewApply.Rows[e.RowIndex].Cells[2].Value);
if (RemAmt > OriginalAmt)
GrdViewApply.Rows[e.RowIndex].Cells[3].Value = RemAmt;
if (GrdViewApply.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != DBNull.Value)
if (Convert.ToDecimal(GrdViewApply.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) > OriginalAmt)
RemAmt = Convert.ToDecimal(GrdViewApply.Rows[e.RowIndex].Cells[2].Value) - enteramt;
//GrdViewApply.Rows[e.RowIndex].Cells[3].Value = DBNull.Value;
// MessageBox.Show("Column No=" + e.ColumnIndex.ToString() + " Row No=" + e.RowIndex.ToString() + " Value =" + GrdViewApply.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() + " Value Type=" + GrdViewApply.Rows[e.RowIndex].Cells[e.ColumnIndex].ValueType.ToString());
MessageBox.Show("Column No=" + e.ColumnIndex.ToString() + " Row No=" + e.RowIndex.ToString());
Could somebody pls help me to achieve this functionality. Your help is greatly appreciated.