private void BtnOK_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                InfoGrid.RefreshDataSource();

                if (BtnOK.Text.ToUpper() == "&OK")
                {
                    InfoGrid.RefreshDataSource();
                    var dr = dt.NewRow();
                    dr["PrdCode"]     = Convert.ToDecimal(txtProductCode.Text);
                    dr["PrdAsgnCode"] = txtProductACode.Text;
                    dr["PrdName"]     = txtProductName.Text;
                    dr["Qty"]         = Convert.ToDecimal(txtProductQty.Text);
                    dr["Amount"]      = Convert.ToDecimal(txtAmount.Text);
                    dt.Rows.Add(dr);
                    if (dt.Rows.Count > 0)
                    {
                        InfoGrid.DataSource = dt;
                        InfoGridView.BestFitColumns();
                    }
                    BtnUndo.PerformClick();
                }
                if (BtnOK.Text.ToUpper() == "&UPDATE")
                {
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdCode"], Convert.ToDecimal(txtProductCode.Text));
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdAsgnCode"], txtProductACode.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["PrdName"], txtProductName.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Qty"], Convert.ToDecimal(txtProductQty.Text));
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Amount"], Convert.ToDecimal(txtAmount.Text));
                    InfoGridView.RefreshData();

                    BtnUndo.PerformClick();
                }
            }
        }
        private void BtnOK_Click(object sender, EventArgs e)
        {
            if (ValidateData())
            {
                InfoGrid.RefreshDataSource();
                if (BtnOK.Text.ToUpper() == "&OK")
                {
                    InfoGrid.RefreshDataSource();
                    var dr = dt.NewRow();
                    dr["AccCode"]   = txtAccCode.Text.Trim();
                    dr["AccName"]   = txtAccName.Text;
                    dr["Narration"] = txtNarration.Text;
                    if (txtDrCr.Text.ToUpper() == "DR")
                    {
                        dr["Debit"] = Convert.ToDecimal(txtAmount.Text);
                    }
                    else
                    {
                        dr["Debit"] = Convert.ToDecimal("0");
                    }
                    if (txtDrCr.Text.ToUpper() == "CR")
                    {
                        dr["Credit"] = Convert.ToDecimal(txtAmount.Text);
                    }
                    else
                    {
                        dr["Credit"] = Convert.ToDecimal("0");
                    }
                    dr["CrDr"]        = txtDrCr.Text;
                    dr["VutChequeNo"] = txtChqNo.Text;
                    if (txtChqDate.Text.Length > 0)
                    {
                        dr["VutChequeDate"] = Convert.ToDateTime(txtChqDate.Text).ToString("yyyy-MM-dd");
                    }
                    dt.Rows.Add(dr);
                    if (dt.Rows.Count > 0)
                    {
                        InfoGrid.DataSource = dt;
                        InfoGridView.BestFitColumns();
                    }
                }


                if (BtnOK.Text.ToUpper() == "&UPDATE")
                {
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["AccCode"], txtAccCode.Text.Trim());
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["AccName"], txtAccName.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Narration"], txtNarration.Text);
                    if (txtDrCr.Text.ToUpper() == "DR")
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Debit"], Convert.ToDecimal(txtAmount.Text));
                    }
                    else
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Debit"], Convert.ToDecimal("0"));
                    }
                    if (txtDrCr.Text.ToUpper() == "CR")
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Credit"], Convert.ToDecimal(txtAmount.Text));
                    }
                    else
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["Credit"], Convert.ToDecimal("0"));
                    }
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["CrDr"], txtDrCr.Text);
                    InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["VutChequeNo"], txtChqNo.Text);
                    if (txtChqDate.Text.Length > 0)
                    {
                        InfoGridView.SetRowCellValue(rowindex, InfoGridView.Columns["VutChequeDate"], Convert.ToDateTime(txtChqDate.Text));
                    }
                    InfoGridView.RefreshData();
                    BtnUndo.PerformClick();
                }
            }
        }