0
I’m developing a basic C# program where the user will enter values through a barcode reader. It will be saved in an Excel spreadsheet for a future report.
My problem is that there are situations where the user beeps the same code twice in different textbox.
I was wondering if, by clicking on my button, Salvar
, had an event to compare all my textbox and check for repeated values, preventing to save duplicate information.
Below is my Button Add code:
private void BtnAdicionar_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application Excel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook sheet = Excel.Workbooks.Open("C:\\Users\\Core i3\\Desktop\\EtiqMasterBoxTornozeleira.xlsx");
Microsoft.Office.Interop.Excel.Worksheet x = Excel.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;
Excel.Range userRanger = x.UsedRange;
int countRecords = userRanger.Rows.Count;
int add = countRecords + 1;
}
Thanks for the help, it worked here, now I just need to implement a method for him not to let save even with duplicate fields, which is what is still happening, but he already accuses that there are duplicate fields. Thank you
– Luiz Felipe