Exemplo n.º 1
0
        private void updateAReaderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Reader reader = new Reader();

            foreach (DataGridViewRow oneRow in dataGridView1.SelectedRows)
            {
                if (oneRow.Selected)
                {
                    int    id      = Convert.ToInt16(oneRow.Cells[0].Value);
                    string name    = oneRow.Cells[1].Value.ToString();
                    string num     = oneRow.Cells[2].Value.ToString();
                    string address = oneRow.Cells[3].Value.ToString();


                    using (var form = new Insert_Reader(name, num, address))
                    {
                        var result = form.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            reader = form.rd;

                            try
                            {
                                this.rEADERSTableAdapter.UpdateReader(reader.getNumber(), reader.getAddress(), id);
                            }
                            catch (System.Exception ex)
                            {
                                System.Windows.Forms.MessageBox.Show(ex.Message);
                            }

                            refreshToolStripMenuItem_Click(sender, e);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void registerAReaderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Reader reader = new Reader();

            using (var form = new Insert_Reader())
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    reader = form.rd;

                    try
                    {
                        this.rEADERSTableAdapter.Insert(reader.getName(), reader.getNumber(), reader.getAddress());
                    }
                    catch (System.Exception ex)
                    {
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }

                    refreshToolStripMenuItem_Click(sender, e);
                }
            }
        }