protected void btnDetails_Click(object sender, EventArgs e) { mvSessionHistory.ActiveViewIndex = 1; int hash = sender.GetHashCode(); foreach (RepeaterItem item in rSessionHistories.Items) { LinkButton button = item.FindControl("btnDetails") as LinkButton; if (button.GetHashCode() == hash) { TableCell tc = item.FindControl("tcSessionID") as TableCell; int SessionID = Convert.ToInt32(tc.Text); using (DatabaseDataContext db = new DatabaseDataContext()) { tblSession session = db.tblSessions.Where(x => x.SessionID == SessionID).FirstOrDefault(); tblUser user = db.tblUsers.Where(x => x.UserID == session.UserID).FirstOrDefault(); lblSessionID.Text = session.SessionID.ToString(); lblUserID.Text = user.UserID.ToString(); lblSessionStart.Text = session.SessionBegin.ToString(); lblSessionLatitude.Text = session.SessionLatitude.ToString(); lblSessionLongitude.Text = session.SessionLongitude.ToString(); // SessionEnd can be empty because it has ALLOW NULL property in database. try { lblSessionEnd.Text = session.SessionEnd.ToString(); } catch (NullReferenceException) { lblSessionEnd.Text = "-"; } } } } }
public void LoadGrid() { //Cbo Load Session var session = db.tblSessions.ToList(); tblSession tbl = new tblSession(); tbl.SessionName = "Choose Session"; session.Insert(0, tbl); cboSessionId.DataSource = session; cboSessionId.DisplayMember = "SessionName"; cboSessionId.ValueMember = "SessionId"; cboSessionId.SelectedIndex = 0; //Cbo Load Faculty var faculty = db.tblFaculties.ToList(); tblFaculty tbf = new tblFaculty(); tbf.FacultyDescription = "Choose Faculty"; faculty.Insert(0, tbf); cboFacultyId.DataSource = faculty; cboFacultyId.DisplayMember = "FacultyDescription"; cboFacultyId.ValueMember = "FacultyId"; cboFacultyId.SelectedIndex = 0; //Selecting List of User & Displaying in Datagrid view dataGridView1.DataSource = db.tblStudents.Select(x => new { StudentId = x.StudentId, StudentName = x.StudentName, Address = x.Address, ContactNumber = x.Contact, SessionName = x.tblSession.SessionName, Faculty = x.tblFaculty.FacultyDescription }).ToList(); }
private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { sessionid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value); tblSession tb = db.tblSessions.Where(u => u.SessionId == sessionid).FirstOrDefault(); txtSessionName.Text = tb.SessionName; dateTimePicker1.Value = Convert.ToDateTime(tb.StartDate); }
protected void btnSubmit_Click(object sender, EventArgs e) { using (DatabaseDataContext con = new DatabaseDataContext()) { #region checks hideAllPlaceholders(); if (SessionManager.UserID == 0) { showError("You must be logged in to use this feature!"); Utilities.clearAllTextBoxes(viewMain); return; } string EncodedResponse = Request.Form["g-Recaptcha-Response"]; bool IsCaptchaValid = (ReCaptcha.Validate(EncodedResponse) == "true" ? true : false); if (!IsCaptchaValid) { showError("Prove that you are not a robot!"); return; } if (string.IsNullOrEmpty(txtEmergTitle.Text)) { showError("Emergency title is empty!"); return; } #endregion tblSession session = con.tblSessions.Where(x => x.SessionID == SessionManager.SessionID).FirstOrDefault(); try { tblEmergency emergency = new tblEmergency { EmergencyTitle = txtEmergTitle.Text, EmergencyLatitude = session.SessionLatitude, EmergencyLongitude = session.SessionLongitude, EmergencyStatus = "Pending", IsSeen = false, EmergencyDate = DateTime.UtcNow, UserID = SessionManager.UserID }; con.tblEmergencies.InsertOnSubmit(emergency); con.SubmitChanges(); showSuccess("Emergency notification has been issued successfully!"); Utilities.clearAllTextBoxes(viewMain); NotificationManager.emergencySent(); } catch (Exception ex) { showError("Error: " + ex); Utilities.clearAllTextBoxes(viewMain); } } }
private void btnDelete_Click(object sender, EventArgs e) { tblSession tb = db.tblSessions.Where(u => u.SessionId == sessionid).FirstOrDefault(); db.tblSessions.Remove(tb); if (db.SaveChanges() > 0) { MessageBox.Show("Session Deleted"); LoadGrid(); } ; }
protected void btnLogout_Click(object sender, EventArgs e) { using (DatabaseDataContext con = new DatabaseDataContext()) { tblSession session = con.tblSessions.Where(x => x.SessionID == SessionManager.SessionID).FirstOrDefault(); SessionManager.UserID = 0; SessionManager.SessionID = 0; session.SessionEnd = DateTime.Now; con.SubmitChanges(); } mvLoginLogout.ActiveViewIndex = 0; }
private void btnUpdate_Click(object sender, EventArgs e) { tblSession tb = db.tblSessions.Where(u => u.SessionId == sessionid).FirstOrDefault(); tb.SessionName = txtSessionName.Text; tb.StartDate = dateTimePicker1.Value; db.tblSessions.Add(tb); if (db.SaveChanges() > 0) { MessageBox.Show("Session Updated"); LoadGrid(); ClearData(); } }
private void btnSave_Click(object sender, EventArgs e) { tblSession tb = new tblSession(); tb.SessionName = txtSessionName.Text; tb.StartDate = dateTimePicker1.Value; db.tblSessions.Add(tb); if (db.SaveChanges() > 0) { MessageBox.Show("Session Added"); LoadGrid(); ClearData(); } }
protected void lbLogout_Click(object sender, EventArgs e) { using (DatabaseDataContext con = new DatabaseDataContext()) { tblSession session = con.tblSessions.Where(x => x.SessionID == SessionManager.SessionID).FirstOrDefault(); SessionManager.UserID = 0; SessionManager.SessionID = 0; if (session != null) { session.SessionEnd = DateTime.Now; con.SubmitChanges(); } Response.Redirect("~/Forms/Public/LoginRegister.aspx"); } }
private void saveLocation(double Latitude, double Longitude) { using (DatabaseDataContext db = new DatabaseDataContext()) { tblSession session = db.tblSessions.Where(x => x.SessionID == SessionID).FirstOrDefault(); if (session.SessionLongitude == 0) { session.SessionLongitude = Longitude; } if (session.SessionLatitude == 0) { session.SessionLatitude = Latitude; } db.SubmitChanges(); } }
public static void LeaveChatRoom(Guid ChatRoomID, HttpContext context) { SessionDBDataContext db = new SessionDBDataContext(); tblSession session = ChatManager.GetSession(context); if (session != null) { var talker = db.tblTalkers.FirstOrDefault( t => t.ChatRoomID == ChatRoomID && t.SessionID == session.UID && t.CheckOutTime == null); if (talker != null) { talker.CheckOutTime = DateTime.Now; db.SubmitChanges(); } } TryToDeleteChatMessageList(ChatRoomID); }
public static bool CreateSession(HttpContext context, string clientAlias) { try { SessionDBDataContext db = new SessionDBDataContext(); tblSession session = new tblSession(); session.SessionID = context.Session.SessionID; session.IP = context.Request.clientHostAddress; if (string.IsNullOrEmpty(clientAlias)) clientAlias = session.IP; session.clientAlias = clientAlias; db.tblSessions.InsertOnSubmit(session); db.SubmitChanges(); return true; } catch { return false; } }
public static bool CreateSession(HttpContext context, string userAlias) { try { SessionDBDataContext db = new SessionDBDataContext(); tblSession session = new tblSession(); session.SessionID = context.Session.SessionID; session.IP = context.Request.UserHostAddress; if (string.IsNullOrEmpty(userAlias)) { userAlias = session.IP; } session.UserAlias = userAlias; db.tblSessions.InsertOnSubmit(session); db.SubmitChanges(); return(true); } catch { return(false); } }
internal bool CreateSession(StartSessionModel objReq) { using (var db = new WizzDataContext()) { try { // var uniqueRequestData = db.tblStudentRequests.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId) && x.isDelete == false).FirstOrDefault(); tblSession sessionObj = new tblSession(); sessionObj.createdDate = DateTime.UtcNow; sessionObj.fromTime = timeConversionMethod(objReq.fromTime); sessionObj.toTime = timeConversionMethod(objReq.toTime); sessionObj.uniqueRequestId = objReq.uniqueRequestId; sessionObj.dayType = Convert.ToInt16(objReq.dayType); sessionObj.isDelete = false; sessionObj.updatedDate = DateTime.UtcNow; sessionObj.studentId = Convert.ToInt64(objReq.userId); sessionObj.tutorId = Convert.ToInt64(objReq.tutorId); sessionObj.isCancelled = false; sessionObj.isComplete = false; sessionObj.homeWork = ""; sessionObj.homeWorkDueDate = ""; sessionObj.isActive = true; sessionObj.isStarted = false; sessionObj.sessionAmount = "0"; sessionObj.sessionNotes = ""; db.tblSessions.InsertOnSubmit(sessionObj); db.SubmitChanges(); return true; } catch (Exception) { return false; } } }
internal bool CreateSession(StartSessionModel objReq) { using (var db=new WizzDataContext()) { try { var uniqueRequestData = db.tblStudentRequests.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId) && x.isDelete == false).FirstOrDefault(); tblSession sessionObj = new tblSession(); sessionObj.createdDate = DateTime.UtcNow; sessionObj.fromTime = timeConversionMethod(objReq.fromTime); sessionObj.toTime = timeConversionMethod(objReq.toTime); sessionObj.uniqueRequestId = uniqueRequestData.uniqueStudentRequestId; sessionObj.isDelete = false; sessionObj.updatedDate = DateTime.UtcNow; sessionObj.studentId = Convert.ToInt64(objReq.userId); sessionObj.tutorId = Convert.ToInt64(objReq.tutorId); db.tblSessions.InsertOnSubmit(sessionObj); db.SubmitChanges(); return true; } catch (Exception) { return false; } } }
// Login button in view 0 of mvMain protected void btnLogin_Click(object sender, EventArgs e) { hideAllPlaceholders(); using (DatabaseDataContext con = new DatabaseDataContext()) { // Check if the user exists string password = SecurityManager.encrypt(txtLoginPassword.Text, txtLoginEmail.Text); List <tblUser> users = con.tblUsers.Where( x => x.UserEmail.Equals(txtLoginEmail.Text) && x.IsVerified.Equals(true) && x.IsVisible.Equals(true) ).ToList(); tblUser user = users.Where(x => SecurityManager.decrypt(x.UserPassword, x.UserEmail).Equals(txtLoginPassword.Text)).FirstOrDefault(); if (user != null) { Session["user"] = user; SessionManager.UserID = user.UserID; // Inserting data on current session. tblSession userSession = new tblSession { UserID = user.UserID, SessionBegin = DateTime.Now, SessionLatitude = 0, SessionLongitude = 0 }; con.tblSessions.InsertOnSubmit(userSession); con.SubmitChanges(); // Storing the session object for later use at Logout. SessionManager.SessionID = userSession.SessionID; // Showing index depending on type of user. if (user.UserTypeID == 3 || user.UserTypeID == 4) { // If the user is a vehicle owner/ped, send them to public Index. Response.Redirect("Index.aspx"); } else if (user.UserTypeID == 1 || user.UserTypeID == 2) { // If user is Official, send them to Admin Index Response.Redirect("~/Forms/Admin/Index.aspx"); } else { showError("Error!", 0); Utilities.clearAllTextBoxes(viewLogin); } } else { showError("Incorrect username / password!", 0); Utilities.clearAllTextBoxes(viewLogin); } } }
internal bool SessionReviewByTutor(SessionReviewModel objReq) { using (var db = new WizzDataContext()) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); if (Convert.ToBoolean(objReq.isreschedule))//if reschedule then homework and session notes is neccessary and than reschedule request { sessionData.homeWork = objReq.homeWork; sessionData.sessionNotes = objReq.sessionNotes; sessionData.isComplete = true; sessionData.sessionAmount = objReq.sessionCost; tblSession sessionObj = new tblSession(); sessionObj.createdDate = DateTime.UtcNow; sessionObj.fromTime = timeConversionMethod(objReq.fromTime); sessionObj.toTime = timeConversionMethod(objReq.toTime); sessionObj.uniqueRequestId = objReq.uniqueRequestId; sessionObj.dayType = Convert.ToInt16(objReq.dayType); sessionObj.isDelete = false; sessionObj.homeWork = objReq.homeWork; sessionObj.sessionNotes = objReq.sessionNotes; sessionObj.updatedDate = DateTime.UtcNow; sessionObj.studentId = Convert.ToInt64(objReq.studentId); sessionObj.tutorId = Convert.ToInt64(objReq.userId); //var studentData = db.tblStudentRequests.Where(x => x.uniqueStudentRequestId == objReq.uniqueRequestId).FirstOrDefault(); //tutorRating.avgRatingTutor = ((tutorRating.avgRatingTutor) + (rating.punctual + rating.knowledgable + rating.helpful) / 3) / 2; //studentData.lat = Convert.ToDouble(studentData); //studentData.longi = Convert.ToDouble(objReq.longitude); //studentData.location = Convert.ToString(objReq.location); db.tblSessions.InsertOnSubmit(sessionObj); } else { sessionData.homeWork = objReq.homeWork; sessionData.sessionNotes = objReq.sessionNotes; sessionData.isComplete = true; sessionData.sessionAmount = objReq.sessionCost; } var objUsers = db.tblInviteFriends.Where(x => x.uniqueRequestId == sessionData.uniqueRequestId).ToList(); if (objUsers.Count > 0) { foreach (var n in objUsers) { if (n.fkFriendId == Convert.ToInt32(objReq.userId) || n.isDelete == true) { continue; } var objUser = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(n.fkFriendId)).FirstOrDefault(); objUser.avgRatingStudent = (Convert.ToDecimal(objUser.avgRatingStudent) + Convert.ToDecimal(objReq.rating)) / 2; db.SubmitChanges(); } } else { var objUser = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(sessionData.studentId)).FirstOrDefault(); objUser.avgRatingStudent = (Convert.ToDecimal(objUser.avgRatingStudent) + Convert.ToDecimal(objReq.rating)) / 2; //db.SubmitChanges(); } db.SubmitChanges(); } //throw new NotImplementedException(); return true; }
public Response SaveSessionMasterDetails(SessionMasterCustomModel objModel) { using (response = new Response()) { using (dbcontext = new SchoolManagementEntities()) { try { response.success = true; if (objModel.SessionId == 0) { var rs = dbcontext.tblSessions.FirstOrDefault(x => x.IsDeleted == false && x.Session == objModel.Session); if (rs == null) { tblSession objAddNew = new tblSession { Session = objModel.Session, Description = objModel.Description, DDate = DateTime.Now, IsActive = true, IsDeleted = false, CreatedBy = objModel.CreatedBy, CreatedDate = DateTime.Now, ModifiedBy = objModel.ModifiedBy, ModifiedDate = DateTime.Now }; dbcontext.tblSessions.Add(objAddNew); dbcontext.SaveChanges(); response.responseData = new { SessionId = objAddNew.SessionId, Session = objAddNew.Session }; response.message = "Record Added Successfully!"; } else { response.success = false; response.message = "Record Already Exists!"; } } else { var rs = dbcontext.tblSessions.FirstOrDefault(x => x.IsDeleted == false && x.Session == objModel.Session && x.SessionId != objModel.SessionId); if (rs == null) { var objUpdate = dbcontext.tblSessions.FirstOrDefault(m => m.SessionId == objModel.SessionId); if (objUpdate != null) { objUpdate.Session = objModel.Session; objUpdate.Description = objModel.Description; objUpdate.ModifiedBy = objModel.ModifiedBy; objUpdate.ModifiedDate = DateTime.Now; dbcontext.SaveChanges(); response.responseData = new { SessionId = objUpdate.SessionId, Session = objUpdate.Session }; response.message = "Record Updated Successfully!"; } } else { response.success = false; response.message = "Record Already Exists!"; } } return(response); } catch (Exception ex) { response.success = false; response.message = ex.Message; return(response); } } } }