示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool degel = true;

            errorProvider1.Clear();
            es.MisEsek = Convert.ToInt32(lblMis.Text);
            try
            {
                es.ShemEsek = txtShemEsek.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtShemEsek, ex.Message);
                degel = false;
            }
            try
            {
                es.ShemIshKesher = txtShemIshKesher.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtShemIshKesher, ex.Message);
                degel = false;
            }
            try
            {
                es.NayadIshKesher = txtNayad.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtNayad, ex.Message);
                degel = false;
            }
            es.Kidomet = cmbkid.Text;
            try
            {
                es.MailIshKesher = txtMailIshKesher.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtMailIshKesher, ex.Message);
                degel = false;
            }
            try
            {
                es.CtovetMisrad = txtCtovet.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtCtovet, ex.Message);
                degel = false;
            }
            es.kodIr = Convert.ToInt32(cmbShemIr.SelectedValue);
            try
            {
                es.MailEsek = txtMailEsek.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtMailEsek, ex.Message);
                degel = false;
            }
            es.kodIr = Convert.ToInt32(cmbShemIr.SelectedValue);
            if (degel)
            {
                if (frmStatus == "NEW")
                {
                    try
                    {
                        es.Add();
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("קרתה שגיאה בהוספה" + ex.Message);
                    }
                }
                if (frmStatus == "UPDATE")
                {
                    try
                    {
                        es.Update();
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("קרתה שגיאה בעדכון" + ex.Message);
                    }
                }
                if (frmStatus == "SHOW")
                {
                    this.Close();
                }
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool degel = true;

            errorProvider1.Clear();
            es.MisEsek = Convert.ToInt32(lblMis.Text);
            try
            {
                es.ShemEsek = txtShemEsek.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtShemEsek, ex.Message);
                degel = false;
            }
            try
            {
                es.ShemIshKesher = txtShemIshKesher.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtShemIshKesher, ex.Message);
                degel = false;
            }
            try
            {
                es.NayadIshKesher = txtNayad.Text;
                if (es.NayadIshKesher.Length < 7)
                {
                    throw new Exception("Number must have seven characters");
                }
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtNayad, ex.Message);
                degel = false;
            }
            es.Kidomet = cmbkid.Text;
            try
            {
                es.MailIshKesher = txtMailIshKesher.Text;
                if (!CheckMail(es.MailIshKesher))
                {
                    throw new Exception("must enter valid email");
                }
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtMailIshKesher, ex.Message);
                degel = false;
            }
            try
            {
                es.CtovetMisrad = txtCtovet.Text;
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtCtovet, ex.Message);
                degel = false;
            }
            es.kodIr = Convert.ToInt32(cmbShemIr.SelectedValue);
            try
            {
                es.MailEsek = txtMailEsek.Text;
                if (!CheckMail(es.MailEsek) && es.MailEsek.ToString() != "")
                {
                    throw new Exception("must enter valid email");
                }
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtMailEsek, ex.Message);
                degel = false;
            }
            es.kodIr = Convert.ToInt32(cmbShemIr.SelectedValue);
            if (degel)
            {
                if (frmStatus == "NEW")
                {
                    try
                    {
                        es.Add();
                        Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("קרתה שגיאה בהוספה" + ex.Message);
                    }
                }
                if (frmStatus == "UPDATE")
                {
                    try
                    {
                        es.Update();
                        Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("קרתה שגיאה בעדכון" + ex.Message);
                    }
                }
                if (frmStatus == "SHOW")
                {
                    Close();
                }
            }
        }