SqlCommand cmd = new SqlCommand("select i.Installment_Amount,i.Paid_Amount, i.Remaining_Amount,i.Due_Date,i.Fine, i.Amount_recieved,i.Transaction_Date, i.Transaction_no,i.Loan_id, i.Paid_with_fine,c.Customer_CNIC from Installment_Payment i, Customer c where exists(select i.Loan_id,c.Loan_id, l.Loan_id,c.Customer_CNIC from Loan l,Customer c, Installment_Payment i where i.Loan_id=c.Loan_id and c.Customer_CNIC='" + cbocnic1.Text + "-" + cbocnic2.Text + "-" + cbocnic3.Text + "')", cn); //MessageBox.Show(query1); cmd.CommandType = CommandType.Text; da = new SqlDataAdapter(cmd); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 0) { MessageBox.Show("The Record for Customer'" + cbocnic1.Text + "-" + cbocnic2.Text + "-" + cbocnic3.Text + "'Does not Exist!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cbocnic1.SelectAll(); cbocnic1.Focus(); } else { for (i = 0; i <= dt.Rows.Count - 1; i++) { int newRowIndex = ins.dataGridView1.Rows.Add(); ins.dataGridView1.Rows[newRowIndex].Cells["Loan_id"].Value = dt.Rows[i]["Loan_id"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Transaction_no"].Value = dt.Rows[i]["Transaction_no"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Installment_Amount"].Value = dt.Rows[i]["Installment_Amount"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Due_Date"].Value = dt.Rows[i]["Due_Date"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Transaction_Date"].Value = dt.Rows[i]["Transaction_Date"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Fine"].Value = dt.Rows[i]["Fine"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Paid_with_fine"].Value = dt.Rows[i]["Paid_with_fine"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Amount_recieved"].Value = dt.Rows[i]["Amount_recieved"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Paid_Amount"].Value = dt.Rows[i]["Paid_Amount"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Remaining_Amount"].Value = dt.Rows[i]["Remaining_Amount"].ToString(); ins.dataGridView1.Rows[newRowIndex].Cells["Customer_CNIC"].Value = dt.Rows[i]["Customer_CNIC"].ToString(); } this.Hide(); ins.ShowDialog(); this.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)