Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            frmClientDetail myForm;

            myForm = new frmClientDetail();
            myForm.edtType.SelectedIndex = 0;

            myForm.ShowDialog();

            if (myForm.DialogResult == DialogResult.OK)
            {
                if (myForm.edtType.Text == "Number")
                {
                    IDX = _tblContactType.AddRec(0, myForm.edtDescription.Text);
                }
                else
                {
                    IDX = _tblContactType.AddRec(1, myForm.edtDescription.Text);
                }

                LoadData();

                foreach (DataGridViewRow ARec in dataGridView1.Rows)
                {
                    if (ARec.Cells[0].Value.ToString() == IDX)
                    {
                        dataGridView1.CurrentCell = ARec.Cells[1];
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void DoEdit()
        {
            try
            {
                frmClientDetail myForm;
                myForm = new frmClientDetail();

                IDX = dataGridView1.CurrentRow.Cells["IDX"].Value.ToString();

                if (dataGridView1.CurrentRow.Cells["Type"].Value.ToString() == "Number")
                {
                    myForm.edtType.SelectedIndex = 1;
                }
                else
                {
                    myForm.edtType.SelectedIndex = 0;
                }


                myForm.edtDescription.Text = dataGridView1.CurrentRow.Cells["Description"].Value.ToString();

                myForm.ShowDialog();

                if (myForm.DialogResult == DialogResult.OK)
                {
                    if (myForm.edtType.Text == "Number")
                    {
                        _tblContactType.EditRec(IDX, 0, myForm.edtDescription.Text);
                    }
                    else
                    {
                        _tblContactType.EditRec(IDX, 1, myForm.edtDescription.Text);
                    }

                    LoadData();

                    foreach (DataGridViewRow ARec in dataGridView1.Rows)
                    {
                        if (ARec.Cells[0].Value.ToString() == IDX)
                        {
                            dataGridView1.CurrentCell = ARec.Cells[1];
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Select a row first");
            }
        }