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

            try
            {
                con.ConnectionString = @"Data Source=DESKTOP-69MM1NJ\SQLEXPRESS;Initial Catalog=NadhamniDB;Integrated Security=True;Pooling=False";
                con.Open();
                SqlCommand cmd = new SqlCommand("insert into Kids(FirstName,Gender,Birthday,Health,Consultation,DrName,LevelOfEducation,Establishment,Adress) values(@FirstName,@Gender,@Birthday,@Health,@Consultation,@DrName,@LevelOfEducation,@Establishment,@Adress)", con);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@FirstName", txt_firstnameKid.Text);
                cmd.Parameters.AddWithValue("@Gender", gender);
                cmd.Parameters.AddWithValue("@Birthday", birthdayKid.Value.ToString());
                cmd.Parameters.AddWithValue("@Health", health);
                cmd.Parameters.AddWithValue("@Consultation", ConsultationKids.Value.ToString());
                cmd.Parameters.AddWithValue("@DrName", txt_docNameKids.Text);
                cmd.Parameters.AddWithValue("@LevelOfEducation", cmb_levelEducation.Text.ToString());
                cmd.Parameters.AddWithValue("@Establishment", txt_establishmentKid.Text);
                cmd.Parameters.AddWithValue("@Adress", txt_AdrKid.Text);


                //Execute Command
                cmd.ExecuteNonQuery();
                MessageBox.Show("success");

                Parents p = new Parents();
                p.Show();
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }
Beispiel #2
0
        private void btnSaveSpouse_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();

            try
            {
                /*if (work.Equals("no"))
                 *  Spousetypeofwork = "unemployment";
                 * else
                 *  Spousetypeofwork = txt_jobSpouse.Text;*/

                con.ConnectionString = @"Data Source=DESKTOP-69MM1NJ\SQLEXPRESS;Initial Catalog=NadhamniDB;Integrated Security=True;Pooling=False";
                con.Open();
                SqlCommand cmd = new SqlCommand("insert into Spouse(FirstName,LastName,Gender,Birthday,Health,Consultation,DrName,Work,TypeOfWork,DaysOfWork) values(@FirstName,@LastName,@Gender,@Birthday,@Health,@Consultation,@DrName,@Work,@TypeOfWork,@DaysOfWork)", con);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@FirstName", txt_firstnameSpouse.Text);
                cmd.Parameters.AddWithValue("@LastName", txt_lastnameSpouse.Text);

                cmd.Parameters.AddWithValue("@Gender", gender);
                cmd.Parameters.AddWithValue("@Birthday", birthdaySpouse.Value.ToString());

                if (rd_HealthySpouse.Checked)
                {
                    health = "healthy";
                    cmd.Parameters.AddWithValue("@Health", health);
                }
                else
                if (rd_SickSpouse.Checked)
                {
                    health = "sick";
                    cmd.Parameters.AddWithValue("@Health", health);
                }
                cmd.Parameters.AddWithValue("@Consultation", ConsultationSpouse.Value.ToString());
                cmd.Parameters.AddWithValue("@DrName", txt_docNameSpouse.Text);
                if (rd_YesWorkSpouse.Checked)
                {
                    work = "yes";
                    cmd.Parameters.AddWithValue("@Work", work);
                    Spousetypeofwork = txt_jobSpouse.Text;
                    cmd.Parameters.AddWithValue("@TypeOfWork", Spousetypeofwork);
                }
                else
                if (rd_NoWorkSpouse.Checked)
                {
                    work = "no";
                    cmd.Parameters.AddWithValue("@Work", work);
                    Spousetypeofwork = "unemployment";
                    cmd.Parameters.AddWithValue("@TypeOfWork", Spousetypeofwork);
                }
                cmd.Parameters.AddWithValue("@DaysOfWork", days);

                //Execute Command
                cmd.ExecuteNonQuery();
                MessageBox.Show("success");

                if (PersonalInformation.kid)
                {
                    Kids k = new Kids();
                    k.Show();
                    this.Hide();
                }
                if (!PersonalInformation.kid && (PersonalInformation.Worker || PersonalInformation.Student || PersonalInformation.unemployed))
                {
                    Parents p = new Parents();
                    p.Show();
                    this.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }
        }
Beispiel #3
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();
                }
            }
        }