Exemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            BLnationality objBLL = new BLnationality();

            Nationality objnat = new Nationality();

            //int row = dataGridView1.CurrentCell.RowIndex;
            string CountryName = txtName.Text;

            try
            {
                int retVal = objBLL.DeleteNationality(CountryName);
                if (retVal > 0)
                {
                    MessageBox.Show("Success");
                }
                else
                {
                    MessageBox.Show("Failed");
                }
            }
            catch //(Exception ex)
            {
            }
            finally
            {
                objnat = null;
                objBLL = null;
            }
            refreshdata();
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            BLnationality objBLL = new BLnationality();

            Nationality objnat = new Nationality();

            objnat.CountryName = txtName.Text;

            objnat.CountryCode = txtCode.Text;


            string val = objBLL.Validate(objnat);

            if (val != "")
            {
                MessageBox.Show(val);

                txtName.Focus();
            }
            else
            {
                try
                {
                    int retVal;

                    if (dgvNationality.CurrentCell == null)
                    {
                        retVal = objBLL.InsertNationality(objnat);
                    }
                    else
                    {
                        retVal = objBLL.UpdateNationality(dgvNationality["CountryName", dgvNationality.CurrentCell.RowIndex].Value.ToString(), objnat);
                    }

                    if (retVal > 0)
                    {
                        MessageBox.Show("Success");
                    }
                    else
                    {
                        MessageBox.Show("Failed");
                    }
                }
                catch //(Exception ex)
                {
                }
                finally
                {
                    objnat = null;

                    objBLL = null;
                }

                refreshdata();
            }
        }
Exemplo n.º 3
0
        private void dgvNationality_SelectionChanged(object sender, EventArgs e)
        {
            BLnationality objBLL = new BLnationality();

            Nationality     objnat = new Nationality();
            DataGridViewRow row    = this.dgvNationality.Rows[dgvNationality.CurrentCell.RowIndex];

            txtName.Text = row.Cells["CountryName"].Value.ToString();
            txtCode.Text = row.Cells["CountryCode"].Value.ToString();
        }