private void btnSaveStudies_Click(object sender, EventArgs e) { starth = cmb_startTimeStudiesH.Text; startm = cmb_startTimeStudiesM.Text; starttime = starth + startm; endh = cmb_EndTimeStudiesH.Text; endm = cmb_EndTimeStudiesM.Text; endtime = endh + endm; SqlConnection con = new SqlConnection(); if (txt_levelStudies.Text == "" || txt_specialty.Text == "" || txt_specialty.Text == "") { if (MondayStudies.Checked == true || TuesdayStudies.Checked == true || wednesdayStudies.Checked == true || ThursdayStudies.Checked == true || fridayStudies.Checked == true || SaturdayStudies.Checked == true || SundayStudies.Checked == true) { MessageBox.Show("Please fill all fields"); 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 Studies(LevelOfStudies,Speciality,Establishment,DaysOfStud,StartTime,EndTime,UserName) values(@LevelOfStudies,@Speciality,@Establishment,@DaysOfStud,@StartTime,@EndTime,@UserName)", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@levelOfStudies", txt_levelStudies.Text); cmd.Parameters.AddWithValue("@Speciality", txt_specialty.Text); cmd.Parameters.AddWithValue("@Establishment", txt_establishment.Text); cmd.Parameters.AddWithValue("@DaysOfStud", days); cmd.Parameters.AddWithValue("@StartTime", starttime); cmd.Parameters.AddWithValue("@EndTime", endtime); cmd.Parameters.AddWithValue("@UserName", Home.FK); //Execute Command cmd.ExecuteNonQuery(); //MessageBox.Show("success"); SuccessJob stud1 = new SuccessJob(); stud1.Show(); /*Dashboard d = new Dashboard(); * d.Show(); * this.Hide();*/ } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } } }
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(); } } } }