public String SaveRoutine(Rutin rutin) { if (!RutinGateway.IsExistDept(rutin.Department, rutin.Gender)) { int rowAffect = RutinGateway.SaveRoutine(rutin); if (rowAffect > 0) { return("Successful!!"); } else { return("Ops! Failed!!"); } } else { int rowAffect = RutinGateway.RoutineUpdate(rutin); if (rowAffect > 0) { return("Class Routine Of Dept. " + rutin.Department + " " + rutin.Gender + " Has been Successfully updated!!"); } else { return("Ops! Failed!!"); } } }
public string Save(Rutin rutin) { if (!RutinGateway.IsExistRutin(rutin)) { int rowAffect = RutinGateway.Save(rutin); if (rowAffect > 0) { return("Successful!!"); } else { return("Ops! Failed!!"); } } else { int rowAffect = RutinGateway.NeedRutinUpdate(rutin); if (rowAffect > 0) { return("Updated Successfuly!!"); } else { return("Ops! Failed!!"); } } }
public String Emergency(Rutin rutin) { int rowAffect = RutinGateway.Emergency(rutin); if (rowAffect > 0) { return("Successful!!"); } else { return("Ops! Failed!!"); } }
public int RoutineUpdate(Rutin rutin) { string query = "update ClassRoutin set ClassRoutine = @classRoutine Where Department = @dept and Gender = @gender"; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@dept", rutin.Department); command.Parameters.AddWithValue("@gender", rutin.Gender); command.Parameters.AddWithValue("@classRoutine", rutin.ClassRoutine); connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
public int SaveRoutine(Rutin rutin) { string query = "Insert Into ClassRoutin(Department,ClassRoutine,Gender) Values(@department,@classRoutine,@gender)"; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@department", rutin.Department); command.Parameters.AddWithValue("@classRoutine", rutin.ClassRoutine); command.Parameters.AddWithValue("@gender", rutin.Gender); connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
public int Save(Rutin rutin) { string query = "Insert Into Rutin(Day,Department,Semester,Gender,StudentNumber) Values(@day,@department,@semester,@gender,@studentNumber)"; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@day", rutin.Day); command.Parameters.AddWithValue("@department", rutin.Department); command.Parameters.AddWithValue("@semester", rutin.Semester); command.Parameters.AddWithValue("@gender", rutin.Gender); command.Parameters.AddWithValue("@studentNumber", rutin.StudentNumber); connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
public bool IsExistRutin(Rutin rutin) { string query = "Select * From Rutin Where Day = @day and Department = @dept and Semester = @semester and Gender = @gender "; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@dept", rutin.Department); command.Parameters.AddWithValue("@gender", rutin.Gender); command.Parameters.AddWithValue("@semester", rutin.Semester); command.Parameters.AddWithValue("@day", rutin.Day); connection.Open(); reader = command.ExecuteReader(); bool isExist = reader.HasRows; connection.Close(); return(isExist); }
protected void Button1_Click(object sender, EventArgs e) { if (departmentDropDownList.SelectedIndex != 0 && semesterDropDownList.SelectedIndex != 0 && dayDropDownList.SelectedIndex != 0 && genderDropDownList.SelectedIndex != 0) { Rutin rutin = new Rutin(); rutin.Day = dayDropDownList.Text; rutin.Department = departmentDropDownList.Text; rutin.Semester = semesterDropDownList.Text; rutin.Gender = genderDropDownList.Text; rutin.StudentNumber = Convert.ToInt32(studentNumberTextBox.Text); outputLabel.Text = rutinManager.Save(rutin); } else { outputLabel.Text = "Please Select All The Box!"; } }
protected void Button1_Click(object sender, EventArgs e) { if (ClassRutine() == true) { if (departmentDropDownList.SelectedIndex != 0 && genderDropDownList.SelectedIndex != 0) { Rutin rutin = new Rutin(); rutin.Department = departmentDropDownList.Text; rutin.Gender = genderDropDownList.Text; rutin.ClassRoutine = routineLink; OutputLabel.Text = rutinManager.SaveRoutine(rutin); } else { OutputLabel.Text = "Please Select All"; } } }
public int NeedRutinUpdate(Rutin rutin) { string query = "update Rutin set StudentNumber = @studentNumber Where Day = @day and Department = @dept and Semester = @semester and Gender = @gender"; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@dept", rutin.Department); command.Parameters.AddWithValue("@gender", rutin.Gender); command.Parameters.AddWithValue("@semester", rutin.Semester); command.Parameters.AddWithValue("@day", rutin.Day); command.Parameters.AddWithValue("@studentNumber", rutin.StudentNumber); connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
public int Emergency(Rutin rutin) { string query = "Insert Into EmergencySchedule(Department,Semester,Date,Time,Location,Way,Gender) Values(@department,@semester,@date,@time,@location,@way,@gender)"; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@department", rutin.Department); command.Parameters.AddWithValue("@semester", rutin.Semester); command.Parameters.AddWithValue("@date", rutin.Date); command.Parameters.AddWithValue("@time", rutin.Time); command.Parameters.AddWithValue("@location", rutin.Location); command.Parameters.AddWithValue("@way", rutin.Way); command.Parameters.AddWithValue("@gender", rutin.Gender); connection.Open(); int rowAffect = command.ExecuteNonQuery(); connection.Close(); return(rowAffect); }
protected void Button1_Click(object sender, EventArgs e) { if (genderDropDownList.SelectedIndex != 0 && semesterDropDownList.SelectedIndex != 0 && departmentDropDownList.SelectedIndex != 0 && locationDropDownList.SelectedIndex != 0 && wayDropDownList.SelectedIndex != 0) { Rutin rutin = new Rutin(); rutin.Department = departmentDropDownList.Text; rutin.Semester = semesterDropDownList.Text; rutin.Location = locationDropDownList.Text; rutin.Way = wayDropDownList.Text; rutin.Gender = genderDropDownList.Text; rutin.Date = fromDateTextBox.Text; rutin.Time = timepickerTextBox.Text; Outputlabel.Text = rutinManager.Emergency(rutin); } else { Outputlabel.Text = "Please Select All The Box"; } }
public List <Rutin> GetEmergencyList() { string query = "Select * From EmergencySchedule"; command = new SqlCommand(query, connection); connection.Open(); reader = command.ExecuteReader(); List <Rutin> schedules = new List <Rutin>(); while (reader.Read()) { Rutin aSchedule = new Rutin(); aSchedule.Department = reader["Department"].ToString(); aSchedule.Semester = reader["Semester"].ToString(); aSchedule.Date = reader["Date"].ToString(); aSchedule.Location = reader["Location"].ToString(); aSchedule.Time = reader["Time"].ToString(); aSchedule.Gender = reader["Gender"].ToString(); aSchedule.Way = reader["Way"].ToString(); if (aSchedule.Way == "City To Varsity") { aSchedule.Way = "Towards Varsity"; } else { aSchedule.Way = "Towards City"; } schedules.Add(aSchedule); } connection.Close(); return(schedules); }
public List <Rutin> GetRoutine() { string query = "SELECT Department,Gender,ClassRoutine From ClassRoutin Group by Department,ClassRoutine,Gender"; command = new SqlCommand(query, connection); connection.Open(); reader = command.ExecuteReader(); List <Rutin> rutinList = new List <Rutin>(); while (reader.Read()) { Rutin aRutin = new Rutin(); aRutin.Department = reader["Department"].ToString(); aRutin.Gender = reader["Gender"].ToString(); aRutin.ClassRoutine = reader["ClassRoutine"].ToString(); rutinList.Add(aRutin); } connection.Close(); return(rutinList); }