Esempio n. 1
0
        private void btnOsef_Click(object sender, EventArgs e)
        {
            bool degel = true;

            errorProvider1.Clear();
            ir.KodIr = Convert.ToInt32(lblKod.Text);
            try
            {
                ir.ShemIr = txtShem.Text;
                for (int i = 0; i < dgvarim.RowCount - 1; i++)
                {
                    if (dgvarim.Rows[i].Cells[1].Value.ToString() == ir.ShemIr)
                    {
                        throw new Exception("cant have duplicate city");
                    }
                }
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtShem, ex.Message);
                degel = false;
            }
            if (degel)
            {
                try
                {
                    ir.Add();
                    groupBox1.Visible = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("הייתה שגיאה בהוספה" + ex.Message);
                }
            }
        }
Esempio n. 2
0
        private void btnOsef_Click(object sender, EventArgs e)
        {
            bool degel = true;

            errorProvider1.Clear();
            try
            {
                ir.KodIr  = Convert.ToInt32(lblKod.Text);
                ir.ShemIr = txtShem.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtShem, ex.Message);
                degel = false;
            }
            if (degel)
            {
                try
                {
                    ir.Add();
                    groupBox1.Visible = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("הייתה שגיאה בהוספה" + ex.Message);
                }
            }
        }