Exemplo n.º 1
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();
            }
        }