Beispiel #1
0
        private void btnSavePersInfo_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = @"Data Source=DESKTOP-69MM1NJ\SQLEXPRESS;Initial Catalog=NadhamniDB;Integrated Security=True;Pooling=False";


            try
            {  //tbar9ich lel BD
                if (days != 0)
                {
                    activity = txt_activityInfo.Text;
                }
                else
                {
                    activity = "no activity";
                }
                if (work.Equals("no"))
                {
                    typeofwork = "unemployment";
                }
                else
                {
                    typeofwork = txt_WorkInfo.Text;
                }

                con.Open();
                SqlCommand cmd = new SqlCommand("update Profile set FirstName=@FirstName,LastName=@LastName,Gender=@Gender,Birthday=@Birthday,Adress=@Adress,Work=@Work,TypeOfWork=@TypeOfWork,Student=@Student,CivilStatus=@CivilStatus,Kids=@Kids,Health=@Health,Consultation=@Consultation,DrName=@DrName,Exercice=@Exercice,TypeOfActivity=@TypeOfActivity,DaysOfPractice=@DaysOfPractice where UserName='******'", con);
                cmd.CommandType = CommandType.Text;
                // Add parameters
                cmd.Parameters.AddWithValue("@FirstName", txt_firstnameInfo.Text);
                cmd.Parameters.AddWithValue("@LastName", txt_lastnameInfo.Text);
                cmd.Parameters.AddWithValue("@Gender", gender);
                cmd.Parameters.AddWithValue("@Birthday", birthdayInfo.Value.ToString());
                cmd.Parameters.AddWithValue("@Adress", txt_AdrInfo.Text);
                cmd.Parameters.AddWithValue("@Work", work);
                cmd.Parameters.AddWithValue("@TypeOfWork", typeofwork);
                cmd.Parameters.AddWithValue("@Student", student);
                cmd.Parameters.AddWithValue("@CivilStatus", CivilStatus);
                cmd.Parameters.AddWithValue("@Kids", kids);
                cmd.Parameters.AddWithValue("@Health", health);
                cmd.Parameters.AddWithValue("@Consultation", ConsultationInfo.Value.ToString());
                cmd.Parameters.AddWithValue("@DrName", txt_docNameInfo.Text);
                cmd.Parameters.AddWithValue("@Exercice", exercice);
                cmd.Parameters.AddWithValue("@TypeOfActivity", activity);
                cmd.Parameters.AddWithValue("@DaysOfPractice", days);

                cmd.ExecuteNonQuery();

                //Moving to the rest of interfaces
                Facebook   f  = new Facebook();
                GooglePlus gp = new GooglePlus();
                twitter    t  = new twitter();
                if (Mar)
                {
                    Spouse sp = new Spouse();
                    sp.Show();
                    this.Hide();
                    f.Hide();
                    gp.Hide();
                    t.Hide();
                }

                if ((wid || Div) && (kid))
                {
                    Kids k = new Kids();
                    k.Show();
                    this.Hide();
                    f.Hide();
                    gp.Hide();
                    t.Hide();
                }
                if (sing)
                {
                    Parents p = new Parents();
                    p.Show();
                    this.Hide();
                    f.Hide();
                    gp.Hide();
                    t.Hide();
                }
                if ((wid || Div) && (!kid))
                {
                    Parents p = new Parents();
                    p.Show();
                    this.Hide();
                    f.Hide();
                    gp.Hide();
                    t.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }