private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView.Columns[e.ColumnIndex].Name == "lnkDeleteRecord") { if (MessageBox.Show("Do you want to Delete This Record", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int rowIndex = Convert.ToInt32(e.RowIndex); // Get the current row int id = Convert.ToInt32(dataGridView.Rows[rowIndex].Cells[1].Value); odeals.DeleteRecord(id); MessageBox.Show("Deleted"); } dataGridView.DataSource = odeals.ShowAllRecords(); } if (dataGridView.Columns[e.ColumnIndex].Name == "lnkViewRecord") { int rowIndex = Convert.ToInt32(e.RowIndex); // Get the current row int id = Convert.ToInt32(dataGridView.Rows[rowIndex].Cells[1].Value); DataTable selectedRecord = odeals.ShowAllRecords(id); edeals.SellerName = selectedRecord.Rows[0][1].ToString(); edeals.SellerSO = selectedRecord.Rows[0][2].ToString(); edeals.SellerRO = selectedRecord.Rows[0][3].ToString(); edeals.PurchaserName = selectedRecord.Rows[0][4].ToString(); edeals.PurchaserSO = selectedRecord.Rows[0][5].ToString(); edeals.PurchaserRO = selectedRecord.Rows[0][6].ToString(); edeals.PlotHouseNo = selectedRecord.Rows[0][7].ToString(); edeals.Phase = selectedRecord.Rows[0][8].ToString(); edeals.StreetNo = selectedRecord.Rows[0][9].ToString(); edeals.RegistrationNo = selectedRecord.Rows[0][10].ToString(); edeals.Catagory = selectedRecord.Rows[0][11].ToString(); edeals.Size = selectedRecord.Rows[0][12].ToString(); edeals.TotalAmount = selectedRecord.Rows[0][13].ToString(); edeals.Biana = selectedRecord.Rows[0][14].ToString(); edeals.BalanceAmount = selectedRecord.Rows[0][15].ToString(); edeals.OnOrBefore = selectedRecord.Rows[0][16].ToString(); edeals.SellerCnic = selectedRecord.Rows[0][17].ToString(); edeals.PurchaserCnic = selectedRecord.Rows[0][18].ToString(); edeals.WitnessOneName = selectedRecord.Rows[0][19].ToString(); edeals.WitnessOneCnic = selectedRecord.Rows[0][20].ToString(); edeals.WitnessTwoName = selectedRecord.Rows[0][21].ToString(); edeals.WitnessTwoCnic = selectedRecord.Rows[0][22].ToString(); try { using (PrintForm frm = new PrintForm(edeals)) { frm.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnInsert_Click(object sender, EventArgs e) { edeals.Date = System.DateTime.Now.ToString("dd/MM/yyyy"); edeals.BalanceAmount = txtBalanceAmount.Text; edeals.Biana = txtBiana.Text; edeals.Catagory = txtCatagory.Text; edeals.OnOrBefore = txtOnOrBefore.Text; edeals.Phase = txtPhase.Text; edeals.PlotHouseNo = txtPlotHouseNo.Text; edeals.PurchaserCnic = txtPurchaserCNIC.Text; edeals.PurchaserName = txtPurchaserName.Text; edeals.PurchaserRO = txtPurchaserRO.Text; edeals.PurchaserSO = txtPurchaserSO.Text; edeals.RegistrationNo = txtRegistrationNo.Text; edeals.SellerCnic = txtSellerCNIC.Text; edeals.SellerName = txtSellerName.Text; edeals.SellerRO = txtSellerRO.Text; edeals.SellerSO = txtSellerSonOf.Text; edeals.Size = txtSize.Text; edeals.StreetNo = txtStreetNo.Text; edeals.TotalAmount = txtTotalAmount.Text; if (!string.IsNullOrWhiteSpace(txtWitnessOneCNIC.Text) && !string.IsNullOrWhiteSpace(txtWitnessOneName.Text) && !string.IsNullOrWhiteSpace(txtWitnessTwoCnic.Text) && !string.IsNullOrWhiteSpace(txtWitnessTwoName.Text)) { edeals.WitnessOneCnic = txtWitnessOneCNIC.Text; edeals.WitnessOneName = txtWitnessOneName.Text; edeals.WitnessTwoCnic = txtWitnessTwoCnic.Text; edeals.WitnessTwoName = txtWitnessTwoName.Text; } else { edeals.WitnessOneCnic = "_______________"; edeals.WitnessOneName = "_______________"; edeals.WitnessTwoCnic = "_______________"; edeals.WitnessTwoName = "_______________"; } try { if (!string.IsNullOrWhiteSpace(txtBalanceAmount.Text) && !string.IsNullOrWhiteSpace(txtBiana.Text) && !string.IsNullOrWhiteSpace(txtCatagory.Text) && !string.IsNullOrWhiteSpace(txtOnOrBefore.Text) && !string.IsNullOrWhiteSpace(txtPhase.Text) && !string.IsNullOrWhiteSpace(txtPlotHouseNo.Text) && !string.IsNullOrWhiteSpace(txtPurchaserCNIC.Text) && !string.IsNullOrWhiteSpace(txtPurchaserName.Text) && !string.IsNullOrWhiteSpace(txtPurchaserRO.Text) && !string.IsNullOrWhiteSpace(txtPurchaserSO.Text) && !string.IsNullOrWhiteSpace(txtRegistrationNo.Text) && !string.IsNullOrWhiteSpace(txtSellerCNIC.Text) && !string.IsNullOrWhiteSpace(txtSellerName.Text) && !string.IsNullOrWhiteSpace(txtSellerRO.Text) && !string.IsNullOrWhiteSpace(txtSellerSonOf.Text) && !string.IsNullOrWhiteSpace(txtSize.Text) && !string.IsNullOrWhiteSpace(txtStreetNo.Text) && !string.IsNullOrWhiteSpace(txtTotalAmount.Text)) { if (MessageBox.Show("Do you want to Save This in Record", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { odeals.Insert(edeals); MessageBox.Show("Record Saved Sucessfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } try { using (PrintForm frm = new PrintForm(edeals)) { frm.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Clear(); } else { MessageBox.Show("Please Fill Out The Information", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }