public int Yearlevel() { int Yearlevel = 0; using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { string Takanashi = @"SELECT Year_level FROM STUDENT_MAIN WHERE Student_ID=@SID"; Rikka.Open(); using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@SID", Session["Student_ID"].ToString()); using (SqlDataReader dr = WickedEye.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { Yearlevel = int.Parse(dr["Year_level"].ToString()); } } } } } return(Yearlevel); }
protected void btnAdd_Click(object sender, EventArgs e) { using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Util audlog = new Util(); Cryptic cs = new Cryptic(); Rikka.Open(); string Takanashi = @"INSERT INTO ADMIN_MAIN(Admin_PW, First_Name, Last_Name, Middle_Name, User_ID, UserType_ID) VALUES(@Admin_PW, @First_Name, @Last_Name, @Middle_Name, @User_ID, @UserType_ID) "; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@Admin_ID", Session["Admin_ID"].ToString()); WickedEye.Parameters.AddWithValue("@First_Name", txtFN.Text); WickedEye.Parameters.AddWithValue("@Last_Name", txtLN.Text); WickedEye.Parameters.AddWithValue("@Middle_Name", txtMN.Text); WickedEye.Parameters.AddWithValue("@User_ID", txtUID.Text); WickedEye.Parameters.AddWithValue("@Admin_PW", txtPass.Text); WickedEye.Parameters.AddWithValue("@UserType_ID", ddlUsers.Text); WickedEye.ExecuteNonQuery(); //Nathaniel Collins S. Ortiz V audlog.AuditLogAdmin(cs.Encrypt("Adding an Admin"), int.Parse(Session["user_id"].ToString()), cs.Encrypt("Added by IT Admin " + Session["first_name"].ToString() + " " + Session["middle_name"].ToString() + " " + Session["last_name"].ToString())); Response.Redirect("ViewAdmin.aspx"); } } }
void ViewSubject() { int yearlvl = Yearlevel(); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"Select Subject_ID, Subject_Name, Subject_Desc from SUBJECT_MAIN WHERE Year_level=@YL"; using (SqlCommand Chuu2Koi = new SqlCommand(Takanashi, Rikka)) { Chuu2Koi.Parameters.AddWithValue("@YL", yearlvl); using (SqlDataAdapter Nibutani = new SqlDataAdapter(Chuu2Koi)) { DataSet Kumin = new DataSet(); Nibutani.Fill(Kumin, "Subject"); lvSubject.DataSource = Kumin; lvSubject.DataBind(); } } } }
void ViewSchedule(int ID) { using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"Select S.ScheduleID, S.Day_Schedule, Time.Timeslot, S.Year_level + ' - ' + Sec.Section_Name AS 'Grade Section', Subj.Subject_Name , Teach.Teacher_FirstName + ', ' + Teach.Teacher_LastName + ' ' + Teach.Teacher_MiddleName AS 'Teacher' from SCHEDULE S INNER JOIN SECTION Sec ON S.Section_ID = Sec.Section_ID INNER JOIN TIMESLOT_MAIN TIME ON S.Timeslot_ID = TIME.Timeslot_ID INNER JOIN SUBJECT_MAIN Subj ON S.Subject_ID = Subj.Subject_ID INNER JOIN TEACHER_MAIN Teach ON Subj.Teacher_ID = Teach.Teacher_ID WHERE Sec.Section_ID = @SID" ; //@"Select ScheduleID, Day_Schedule, Timeslot from SCHEDULE"; //@"Select S.ScheduleID, S.Day_Schedule, S.Timeslot, S.Year_level, Sec.Section_Name from SCHEDULE S // INNER JOIN SECTION Sec ON S.Section_ID = Sec.Section_ID" using (SqlCommand Chuu2Koi = new SqlCommand(Takanashi, Rikka)) { Chuu2Koi.Parameters.AddWithValue("@SID", ID); using (SqlDataAdapter Nibutani = new SqlDataAdapter(Chuu2Koi)) { DataSet Kumin = new DataSet(); Nibutani.Fill(Kumin, "Schedule"); lvSched.DataSource = Kumin; lvSched.DataBind(); } } } }
protected void btnUpdate_Click(object sender, EventArgs e) { using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Util audlog = new Util(); Cryptic DE = new Cryptic(); Rikka.Open(); string Takanashi = @"UPDATE ENCODING_STATUS SET Quarter_ID=@QID, SY_ID=@SY WHERE EncodingStat_ID=1"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@Admin_ID", Session["Admin_ID"].ToString()); //Subject WickedEye.Parameters.AddWithValue("@QID", ddlQT.Text); WickedEye.Parameters.AddWithValue("@SY", ddlSY.Text); WickedEye.ExecuteNonQuery(); //Nathaniel Collins S. Ortiz audlog.AuditLogAdmin(DE.Encrypt("Assigned SY and Quarter"), int.Parse(Session["admin_id"].ToString()), DE.Encrypt("School Year and Quarter assigned by " + Session["first_name"].ToString() + " " + Session["middle_name"].ToString() + " " + Session["last_name"].ToString())); Response.Redirect("EnableEncoding.aspx"); } } }
public static int Yearlevel(int ID) { int Yearlevel = 0; using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { string Takanashi = @" SELECT Year_level FROM SCHEDULE WHERE ScheduleID=@SID"; Rikka.Open(); using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@SID", ID); using (SqlDataReader dr = WickedEye.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { Yearlevel = int.Parse(dr["Year_level"].ToString()); } } } } } return(Yearlevel); }
void GetSections() { int statID = HomeroomStatID(int.Parse(Request.QueryString["ID"].ToString())); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); Cryptic DE = new Cryptic(); if (statID == 2) { string Takanashi = @"SELECT Section_ID, Section_Name + ' - ' + Year_Level AS 'Section Name' FROM SECTION WHERE HomeStat!=1"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { using (SqlDataReader Chuu2 = WickedEye.ExecuteReader()) { ddlSection.DataSource = Chuu2; ddlSection.DataTextField = "Section Name"; ddlSection.DataValueField = "Section_ID"; ddlSection.DataBind(); ddlSection.Items.Insert(0, new ListItem("Select a Section.", "")); } } } else { ddlSection.Items.Insert(0, new ListItem("Cannot select a section.", "")); } } }
protected void btnUpdate_Click(object sender, EventArgs e) { using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Util audlog = new Util(); Cryptic DE = new Cryptic(); Rikka.Open(); string Takanashi = @"UPDATE TEACHER_MAIN SET Section_ID=@Section_ID, HomeroomStat_ID=@HID WHERE Teacher_ID=@Teacher_ID UPDATE SECTION SET HomeStat=@HomeID WHERE Section_ID=@Sec_ID"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@Admin_ID", Session["Admin_ID"].ToString()); //Subject WickedEye.Parameters.AddWithValue("@Section_ID", ddlSection.Text); WickedEye.Parameters.AddWithValue("@HID", 1); WickedEye.Parameters.AddWithValue("@Teacher_ID", Request.QueryString["ID"].ToString()); WickedEye.Parameters.AddWithValue("@HomeID", 1); WickedEye.Parameters.AddWithValue("@Sec_ID", ddlSection.Text); WickedEye.ExecuteNonQuery(); //Nathaniel Collins S. Ortiz audlog.AuditLogAdmin(DE.Encrypt("Assigning Faculty with Homeroom Adviser"), int.Parse(Session["user_id"].ToString()), DE.Encrypt("Faculty assigned by Principal " + Session["first_name"].ToString() + " " + Session["middle_name"].ToString() + " " + Session["last_name"].ToString())); Response.Redirect("FacultyList.aspx"); } } }
public ActionResult AddCourse(CourseModel rec) { if (IsExisting(rec.Code)) { ViewBag.Error = "<div class='alert alert-danger'> Course Already existed! </div>"; return(View()); } else { using (SqlConnection kek = new SqlConnection(Dekomori.GetConnection())) { kek.Open(); string lel = @"INSERT INTO Courses VALUES (@Code,@Name,@Units,@DateAdded)"; using (SqlCommand ehe = new SqlCommand(lel, kek)) { ehe.Parameters.AddWithValue("@Code", rec.Code); ehe.Parameters.AddWithValue("@Name", rec.Name); ehe.Parameters.AddWithValue("@Units", rec.Units); ehe.Parameters.AddWithValue("@DateAdded", DateTime.Now); ehe.ExecuteNonQuery(); return(RedirectToAction("ViewCourses")); } } } }
// GET: Grade public ActionResult ViewGrades() { var list = new List <GradesModel>(); using (SqlConnection con = new SqlConnection(Dekomori.GetConnection())) { con.Open(); string query = @"SELECT g.CourseID, g.GradeID,c.Code,c.Name,g.Grade,c.Units FROM Grades AS g INNER JOIN Courses c ON g.CourseID = c.CourseID"; using (SqlCommand com = new SqlCommand(query, con)) { using (SqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { list.Add(new GradesModel { CourseID = int.Parse(dr["CourseID"].ToString()), GradeID = int.Parse(dr["GradeID"].ToString()), Code = dr["Code"].ToString(), Name = dr["Name"].ToString(), Grade = decimal.Parse(dr["Grade"].ToString()), Units = dr["Units"].ToString() }); } //ViewBag.TotalGrades = GetTotalGrades().ToString(); ViewBag.TotalUnits = GetTotalUnits().ToString("#.0"); ViewBag.TotalGPA = GetTotalScore() / GetTotalUnits(); } } } return(View(list)); }
protected void btnUpdate_Click(object sender, EventArgs e) { using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Cryptic DE = new Cryptic(); Dekomori audlog = new Dekomori(); Rikka.Open(); string Takanashi = @"UPDATE ADMIN_MAIN SET User_ID=@User_ID, UserType_ID=@UserType_ID, Admin_PW=@PW WHERE Admin_ID=@Admin_ID"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@AID", Session["Admin_ID"].ToString()); //Admin Access Level WickedEye.Parameters.AddWithValue("@User_ID", txtUID.Text); WickedEye.Parameters.AddWithValue("@UserType_ID", ddlUsers.Text); WickedEye.Parameters.AddWithValue("@PW", txtPass.Text); WickedEye.Parameters.AddWithValue("@Admin_ID", Request.QueryString["ID"].ToString()); WickedEye.ExecuteNonQuery(); //Nathaniel Collins S. Ortiz V audlog.AuditLogAdmin(DE.Encrypt("Editing an Admin"), int.Parse(Session["user_id"].ToString()), DE.Encrypt("Edited by IT Admin" + Session["first_name"].ToString() + " " + Session["middle_name"].ToString() + " " + Session["last_name"].ToString())); Response.Redirect("ViewAdmin.aspx"); } } }
// GET: Course public ActionResult ViewCourses() { var list = new List <CourseModel>(); using (SqlConnection con = new SqlConnection(Dekomori.GetConnection())) { con.Open(); string query = "SELECT CourseID, Code, Name, Units, DateAdded FROM Courses"; using (SqlCommand com = new SqlCommand(query, con)) { using (SqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { list.Add(new CourseModel { CourseID = int.Parse(dr["CourseID"].ToString()), Code = dr["Code"].ToString(), Name = dr["Name"].ToString(), Units = decimal.Parse(dr["Units"].ToString()), DateAdded = DateTime.Parse(dr["DateAdded"].ToString()) }); } } } } return(View(list)); }
void GetSubj() { int yearlvl = Yearlevel(int.Parse(Request.QueryString["ID"].ToString())); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"SELECT Subject_ID, Subject_Name FROM SUBJECT_MAIN WHERE Teacher_ID=@TID AND Year_level = @YL"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@TID", Session["Teacher_ID"].ToString()); WickedEye.Parameters.AddWithValue("@YL", yearlvl); using (SqlDataReader Chuu2 = WickedEye.ExecuteReader()) { ddlSubject.DataSource = Chuu2; ddlSubject.DataTextField = "Subject_Name"; ddlSubject.DataValueField = "Subject_ID"; ddlSubject.DataBind(); ddlSubject.Items.Insert(0, new ListItem("Select a subject.", "")); } } } }
public static int Quarter() { int Quarter = 0; using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { string Takanashi = @" SELECT Quarter_ID FROM ENCODING_STATUS WHERE EncodingStat_ID=1"; Rikka.Open(); using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { using (SqlDataReader dr = WickedEye.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { Quarter = int.Parse(dr["Quarter_ID"].ToString()); } } } } } return(Quarter); }
public ActionResult EditRestaurant(RestaurantModel rec, int?id, HttpPostedFileBase image) { using (SqlConnection con = new SqlConnection(Dekomori.GetConnection())) { con.Open(); string query = @"UPDATE RSG_Restaurants SET RSG_CatID=@RCA, RSG_RName=@RN,RSG_Address=@RA,RSG_ContactNumber=@RC, RSG_Manager=@RM, RSG_Branch=@RB, RSG_OperatingHours=@RO,RSG_Status=@RS,RSG_Image=@RI, RSG_TotalSeats=@RTS,RSG_DateModified=@RD WHERE RSG_RID=@RID"; using (SqlCommand com = new SqlCommand(query, con)) { com.Parameters.AddWithValue("@RCA", rec.CatID); com.Parameters.AddWithValue("@RN", rec.Restaurant); com.Parameters.AddWithValue("@RA", rec.Address); com.Parameters.AddWithValue("@RC", rec.Phone); com.Parameters.AddWithValue("@RM", rec.Manager); com.Parameters.AddWithValue("@RB", rec.Branch); com.Parameters.AddWithValue("@RO", rec.OperatingHours); com.Parameters.AddWithValue("@RS", rec.Status); string fileName = DateTime.Now.ToString("yyyyMMddHHmmss-") + image.FileName; com.Parameters.AddWithValue("@RI", fileName); // Upload the chosen file to images > products image.SaveAs(Server.MapPath("~/Images/Restaurants/" + fileName)); com.Parameters.AddWithValue("@RTS", rec.TotalSeats); com.Parameters.AddWithValue("@RD", DateTime.Now); com.Parameters.AddWithValue("@RID", id); com.ExecuteNonQuery(); ViewBag.Success = "<div class='alert alert-success col-lg-6'>Profile Updated </div>"; return(RedirectToAction("ViewOwnedRestaurant", "RestaurantView")); } } }
// Approve Restaurant Application from Patron (User Type) // If Approved -> User Type will change from Patron to Owner public ActionResult ApproveApplication(int?restaurantid) { if (restaurantid == null) { return(RedirectToAction("RestaurantList")); } using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"UPDATE RSG_Restaurants SET RSG_ApprovalID=@RSG_ApprovalID, RSG_DateAdded=@DateAdded WHERE RSG_RID=@RSG_RID UPDATE RSG_Users SET RSG_UserTypeID=@RSG_UserTypeID WHERE RSG_UserID@=RSG_UserID"; using (SqlCommand cmd = new SqlCommand(Takanashi, Rikka)) { cmd.Parameters.AddWithValue("@RSG_ApprovalID", 2); cmd.Parameters.AddWithValue("@DateAdded", DateTime.Now); cmd.Parameters.AddWithValue("@RSG_RID", restaurantid); cmd.ExecuteNonQuery(); } } return(RedirectToAction("RestaurantList")); }
public List <SelectListItem> GetCategories() { var list = new List <SelectListItem>(); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"SELECT RSG_CatID, RSG_Category FROM RSG_Categories ORDER BY RSG_Category"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { using (SqlDataReader Nibutani = WickedEye.ExecuteReader()) { while (Nibutani.Read()) { list.Add(new SelectListItem { Value = Nibutani["RSG_CatID"].ToString(), Text = Nibutani["RSG_Category"].ToString() }); } } } } return(list); }
public ActionResult AddGrades(GradesModel rec) { //if (IsExisting(rec.CourseID)) //{ // ViewBag.Error = "<div class='alert alert-danger'> Subject Already added </div>"; // return View(); //} //else //{ using (SqlConnection con = new SqlConnection(Dekomori.GetConnection())) { con.Open(); string query = @"INSERT INTO Grades VALUES (@SN,@CourseID,@Grade,@Total)"; using (SqlCommand com = new SqlCommand(query, con)) { com.Parameters.AddWithValue("@SN", rec.StudentName); com.Parameters.AddWithValue("@CourseID", rec.CourseID); com.Parameters.AddWithValue("@Grade", rec.Grade); com.Parameters.AddWithValue("@Total", DBNull.Value); com.ExecuteNonQuery(); } } return(RedirectToAction("ViewGrades")); //} }
public List <CourseModel> GetCourses() { var list = new List <CourseModel>(); using (SqlConnection con = new SqlConnection(Dekomori.GetConnection())) { con.Open(); string query = @"SELECT CourseID, Code FROM Courses"; using (SqlCommand com = new SqlCommand(query, con)) { using (SqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { list.Add(new CourseModel { CourseID = int.Parse(dr["CourseID"].ToString()), Code = dr["Code"].ToString() }); } } } } return(list); }
//public List<CheckInModel> GetCheckIns() //{ // var list = new List<CheckInModel>(); // using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) // { // Rikka.Open(); // string Takanashi = @"SELECT COUNT (RSG_LogID) AS TotalCheckIn FROM RSG_CheckIn WHERE RSG_RID=@RSG_ID"; // using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) // { // using (SqlDataReader Nibutani = WickedEye.ExecuteReader()) // { // while (Nibutani.Read()) // { // list.Add(new CheckInModel // { // CheckInID = int.Parse(Nibutani["RSG_LogID"].ToString()), // TotalCheckIn = int.Parse(Nibutani["TotalCheckIn"].ToString()), // RestaurantID = int.Parse(Nibutani["RSG_RID"].ToString()) // }); // } // } // return list; // } // } //} public List <CategoriesModel> GetCategories() { var list = new List <CategoriesModel>(); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"SELECT c.RSG_CatID, c.RSG_Category, (SELECT COUNT(r.RSG_RID) FROM RSG_Restaurants r WHERE r.RSG_CatID = c.RSG_CatID) AS TotalCount FROM RSG_Categories c ORDER BY c.RSG_Category"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { using (SqlDataReader data = WickedEye.ExecuteReader()) { while (data.Read()) { list.Add(new CategoriesModel { CatID = int.Parse(data["RSG_CatID"].ToString()), Name = data["RSG_Category"].ToString(), TotalCount = int.Parse(data["TotalCount"].ToString()) }); } } return(list); } } }
public int HomeroomStatID(int ID) { int HomeroomStatID = 0; using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { string Takanashi = @"SELECT HomeroomStat_ID FROM TEACHER_MAIN WHERE Teacher_ID=@Teacher_ID"; Rikka.Open(); using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@Teacher_ID", Request.QueryString["ID"].ToString()); using (SqlDataReader dr = WickedEye.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { HomeroomStatID = int.Parse(dr["HomeroomStat_ID"].ToString()); } } } } } return(HomeroomStatID); }
void GetData(int ID) { using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { string Takanashi = @"SELECT Admin_ID, User_ID, Admin_PW, First_Name + ', ' + Last_Name + ' ' + Middle_Name AS 'Admin Name' FROM ADMIN_MAIN WHERE Admin_ID=@Admin_ID"; Rikka.Open(); using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@Admin_ID", ID); using (SqlDataReader Chuu2 = WickedEye.ExecuteReader()) { if (Chuu2.HasRows) { while (Chuu2.Read()) { ltID.Text = Chuu2["Admin Name"].ToString(); txtUID.Text = Chuu2["User_ID"].ToString(); txtPass.Text = Chuu2["Admin_PW"].ToString(); } } else { Response.Redirect("ViewAdmin.aspx"); } } } } }
public ActionResult Profile() { if (Session["userid"] == null) { return(RedirectToAction("Login")); } var record = new UsersModel(); using (SqlConnection cheese = new SqlConnection(Dekomori.GetConnection())) { cheese.Open(); string query = @"SELECT RSG_Username,RSG_UPassword,RSG_Email,RSG_FirstName,RSG_LastName, RSG_Address,RSG_Mobile FROM RSG_Users WHERE RSG_UserID =@RG AND RSG_UserTypeID = @RTY"; using (SqlCommand com = new SqlCommand(query, cheese)) { com.Parameters.AddWithValue("@RG", Session["userid"].ToString()); com.Parameters.AddWithValue("@RTY", Session["typeid"].ToString()); using (SqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { record.Username = dr["RSG_Username"].ToString(); record.UserPassword = dr["RSG_UPassword"].ToString(); record.Email = dr["RSG_Email"].ToString(); record.FirstName = dr["RSG_FirstName"].ToString(); record.LastName = dr["RSG_LastName"].ToString(); record.Address = dr["RSG_Address"].ToString(); record.Mobile = dr["RSG_Mobile"].ToString(); } return(View(record)); } } } }
//HomePage Variations between Users //Different Users have different homepages //Patron - UserType #1 //Should display Patron's favorite restaurants public ActionResult UserHome() { if (Session["userid"] == null) // user has not logged in { return(RedirectToAction("Login")); } var list = new List <RestaurantModel>(); using (SqlConnection con = new SqlConnection(Dekomori.GetConnection())) { con.Open(); string cheese = @"SELECT RSG_RID ,RSG_Image FROM RSG_Restaurants WHERE RSG_IsFeatured= 'Yes'"; using (SqlCommand com = new SqlCommand(cheese, con)) { //com.Parameters.AddWithValue("@Is", "Yes"); using (SqlDataReader dr = com.ExecuteReader()) { while (dr.Read()) { list.Add(new RestaurantModel { Image = dr["RSG_Image"].ToString(), RestaurantID = int.Parse(dr["RSG_RID"].ToString()) }); } } } } return(View("HomePageUser", list)); }
int GetTotalCheckIns(int?id) { int Total = 0; using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"SELECT Count(RSG_CheckStatID) AS TOTAL FROM RSG_CheckStat WHERE RSG_Description = @RD AND RSG_RID =@RID"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@RID", id); WickedEye.Parameters.AddWithValue("@RD", "Checked-in"); using (SqlDataReader Nibutani = WickedEye.ExecuteReader()) { if (Nibutani.HasRows) { while (Nibutani.Read()) { Total = int.Parse(Nibutani["TOTAL"].ToString()); } } } } } return(Total); }
// Check-Out for Patron(s) public ActionResult CheckOut(int?id) { if (id == null) { return(RedirectToAction("Favor")); } using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"INSERT INTO RSG_CheckOut VALUES (@RSG_UserID, @RSG_RID, @RSG_Remarks, @RSG_DateAdded) UPDATE RSG_CheckStat SET RSG_RID=@RSG_RID, RSG_Description=@RD WHERE RSG_UserID=@RSG_UserID"; using (SqlCommand cmd = new SqlCommand(Takanashi, Rikka)) { cmd.Parameters.AddWithValue("@RSG_UserID", Session["userid"].ToString()); cmd.Parameters.AddWithValue("@RSG_RID", id); cmd.Parameters.AddWithValue("@RSG_Remarks", "Check-in"); cmd.Parameters.AddWithValue("@RD", "Checked-out"); cmd.Parameters.AddWithValue("@RSG_DateAdded", DateTime.Now); cmd.ExecuteNonQuery(); } } return(RedirectToAction("Index")); }
// View Customer Reviews public ActionResult ViewRatings(int?id) { var list = new List <RatingsModel>(); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"SELECT r.RSG_Cleanliness, r.RSG_CustomerService, r.RSG_FoodQuality, r.RSG_Remarks, u.RSG_Username FROM RSG_Ratings r INNER JOIN RSG_Users u ON r.RSG_UserID = u.RSG_UserID WHERE r.RSG_RID = @RSG_RID"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@RSG_RID", id); using (SqlDataReader data = WickedEye.ExecuteReader()) { while (data.Read()) { list.Add(new RatingsModel { Cleanliness = int.Parse(data["RSG_Cleanliness"].ToString()), CustomerService = int.Parse(data["RSG_CustomerService"].ToString()), FoodQuality = int.Parse(data["RSG_FoodQuality"].ToString()), Remarks = data["RSG_Remarks"].ToString(), User = data["RSG_Username"].ToString() }); } } } } return(View(list)); }
// View Raing public ActionResult ViewAVGRating(int id) { var list = new List <RatingsModel>(); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"SELECT AVG(RSG_Cleanliness) AS Cleanliness, AVG(RSG_CustomerService) AS CustomerService, AVG(RSG_FoodQuality) AS FoodQuality FROM RSG_Ratings WHERE RSG_RID = @RSG_RID"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@RSG_RID", id); using (SqlDataReader data = WickedEye.ExecuteReader()) { while (data.Read()) { list.Add(new RatingsModel { Cleanliness = int.Parse(data["Cleanliness"].ToString()), CustomerService = int.Parse(data["CustomerService"].ToString()), FoodQuality = int.Parse(data["FoodQuality"].ToString()), }); } } } return(View(list)); } }
public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index")); } var Chuu2 = new CheckStatusModel(); using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Rikka.Open(); string Takanashi = @"SELECT r.RSG_CheckStatID, r.RSG_RID, res.RSG_RName, res.RSG_Image, res.RSG_RName, u.RSG_Username, res.RSG_Address, res.RSG_ContactNumber, res.RSG_Branch, res.RSG_OperatingHours,res.RSG_TotalSeats, c.RSG_Category FROM RSG_CheckStat r INNER JOIN RSG_Restaurants res ON r.RSG_RID = res.RSG_RID INNER JOIN RSG_Categories c ON res.RSG_CatID = c.RSG_CatID INNER JOIN RSG_Users u ON r.RSG_UserID = u.RSG_UserID WHERE r.RSG_RID = @RID"; using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@RID", id); using (SqlDataReader Nibutani = WickedEye.ExecuteReader()) { if (Nibutani.HasRows) { while (Nibutani.Read()) { Chuu2.RestaurantID = int.Parse(Nibutani["RSG_RID"].ToString()); Chuu2.RestaurantName = Nibutani["RSG_RName"].ToString(); Chuu2.Address = Nibutani["RSG_Address"].ToString(); Chuu2.Image = Nibutani["RSG_Image"].ToString(); Chuu2.Branch = Nibutani["RSG_Branch"].ToString(); Chuu2.ContactNumber = Nibutani["RSG_ContactNumber"].ToString(); Chuu2.Owner = Nibutani["RSG_Username"].ToString(); Chuu2.TotalSeats = Nibutani["RSG_TotalSeats"].ToString(); Chuu2.OperatingHours = Nibutani["RSG_OperatingHours"].ToString(); Chuu2.Category = Nibutani["RSG_Category"].ToString(); Chuu2.CheckStatusID = int.Parse(Nibutani["RSG_CheckStatID"].ToString()); } ViewBag.Total = (GetTotalCheckIns(id).ToString()); return(View(Chuu2)); } else { return(RedirectToAction("Index")); } } } } }
//WickedEye.CommandText = "SELECT COUNT(*) from SUBJECT_MAIN "; // Int32 count = (Int32)WickedEye.ExecuteScalar(); //void Count() //{ // using (SqlConnection con = new SqlConnection(Util.GetConnection())) // { // con.Open(); // string pleasefortheloveofgodwok = "SELECT COUNT(*) from SUBJECT_MAIN where Teacher_ID=@TID"; // using (SqlCommand com = new SqlCommand(pleasefortheloveofgodwok, con)) // { // com.Parameters.AddWithValue("@TID", ddlTeacher.Text); // com.ExecuteNonQuery(); // } // } //} protected void btnUpdate_Click(object sender, EventArgs e) { using (SqlConnection Rikka = new SqlConnection(Dekomori.GetConnection())) { Util audlog = new Util(); Cryptic DE = new Cryptic(); Rikka.Open(); string Takanashi = @"UPDATE SUBJECT_MAIN SET Teacher_ID=@Teacher_ID WHERE Subject_ID=@Subject_ID"; string gg = "SELECT COUNT(Teacher_ID) from SUBJECT_MAIN where Teacher_ID= '" + ddlTeacher.Text + "'"; SqlCommand com = new SqlCommand(gg, Rikka); int count = Convert.ToInt32(com.ExecuteScalar().ToString()); using (SqlCommand WickedEye = new SqlCommand(Takanashi, Rikka)) { WickedEye.Parameters.AddWithValue("@Admin_ID", Session["Admin_ID"].ToString()); //Subject WickedEye.Parameters.AddWithValue("@Teacher_ID", ddlTeacher.Text); WickedEye.Parameters.AddWithValue("@Subject_ID", Request.QueryString["ID"].ToString()); if (count == 2) { error.Visible = true; } else { WickedEye.ExecuteNonQuery(); Rikka.Close(); audlog.AuditLogAdmin(DE.Encrypt("Assigning Faculty with Subject"), int.Parse(Session["user_id"].ToString()), DE.Encrypt("Faculty assigned by Principal " + Session["first_name"].ToString() + " " + Session["middle_name"].ToString() + " " + Session["last_name"].ToString())); Session["add"] = add.Text; Response.Redirect("ViewSubject.aspx"); } //SqlDataReader dr = WickedEye.ExecuteReader(); //int count=2; //if (dr.HasRows) //{ // while (dr.Read()) // { // } //} //else //{ // error.Visible = true; //} //Nathaniel Collins S. Ortiz } } }