Пример #1
0
        private void btnSaveJob_Click(object sender, EventArgs e)
        {
            starth    = cmb_startTimeJobH.Text;
            startm    = cmb_endTimeJobM.Text;
            starttime = starth + startm;
            endh      = cmb_endTimeJobH.Text;
            endm      = cmb_endTimeJobM.Text;
            endtime   = endh + endm;


            SqlConnection con = new SqlConnection();

            if (txt_hierStatus.Text == "" || txt_specialtyJob.Text == "" || txt_establishmentJob.Text == "")
            {
                if (MondayJob.Checked == true || TuesdayJob.Checked == true || wednesdayJob.Checked == true || ThursdayJob.Checked == true || fridayJob.Checked == true || SaturdayJob.Checked == true || SundayJob.Checked == true)
                {
                    //MessageBox.Show("Please fill all fields");
                    EmptyFields ef2 = new EmptyFields();
                    ef2.Show();
                    return;
                }
            }
            else
            {
                try
                {
                    con.ConnectionString = @"Data Source=DESKTOP-69MM1NJ\SQLEXPRESS;Initial Catalog=NadhamniDB;Integrated Security=True;Pooling=False";
                    con.Open();
                    SqlCommand cmd = new SqlCommand("insert into Job(HierarchicalStatus,Department,Establishment,DaysOfWork,StartTime,EndTime,UserName) values(@HierarchicalStatus,@Department,@Establishment,@DaysOfWork,@StartTime,@EndTime,@UserName)", con);
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@HierarchicalStatus", txt_hierStatus.Text);
                    cmd.Parameters.AddWithValue("@Department", txt_specialtyJob.Text);
                    cmd.Parameters.AddWithValue("@Establishment", txt_establishmentJob.Text);
                    cmd.Parameters.AddWithValue("@DaysOfWork", days);
                    cmd.Parameters.AddWithValue("@StartTime", starttime);
                    cmd.Parameters.AddWithValue("@EndTime", endtime);
                    cmd.Parameters.AddWithValue("@UserName", Home.FK);

                    //Execute Command
                    cmd.ExecuteNonQuery();
                    sj.Show();

                    /* Dashboard d = new Dashboard();
                     * d.Show();
                     * this.Hide();*/
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
        }
Пример #2
0
 private void btn_signIn_Click(object sender, EventArgs e)
 {
     try
     {
         con.Open();
         cmd.Connection  = con;
         cmd.CommandText = "select * from Profile where UserName='******'";
         dr = cmd.ExecuteReader();
         if (dr.HasRows)
         {   //get the FK
             FK = txt_username.Text;
             Boolean ok = false;
             while (dr.Read() && ok == false)
             {
                 if (!txt_password.Text.Equals(dr["Password"]))
                 {
                     PasswordCheck pw = new PasswordCheck();
                     pw.Show();
                     // MessageBox.Show("You need to check your password!");
                     ok = true;
                 }
                 else if (!txt_Email.Text.Equals(dr["Email"]))
                 { //MessageBox.Show("You need to check your E-mail!");
                     EmailCheck ec = new EmailCheck();
                     ec.Show();
                     ok = true;
                 }
             }
             if (ok == false)
             {
                 dsh.Show();
                 this.Hide();
                 fb.Hide();
                 tw.Hide();
                 gp.Hide();
             }
         }
         else
         {
             if (txt_password.Text.Equals("") && txt_Email.Text.Equals("") && txt_username.Text.Equals(""))
             {
                 // MessageBox.Show("The fields are empty");
                 EmptyFields ep = new EmptyFields();
                 ep.Show();
             }
             else
             {
             }
             // MessageBox.Show("You need to register!");
             CheckRegistration crg1 = new CheckRegistration();
             crg1.Show();
             dr.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         if (con.State == ConnectionState.Open)
         {
             con.Close();
         }
     }
 }