public bool Insert(StudentHouseLeave studentHouseLeave, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_StudentHouseLeaveInsert"); db.AddInParameter(command, "HouseId", DbType.Guid, studentHouseLeave.HouseId); db.AddInParameter(command, "BaseHouseRoomId", DbType.Guid, studentHouseLeave.BaseHouseRoomId); db.AddInParameter(command, "RequestBy", DbType.Guid, studentHouseLeave.RequestBy); db.AddInParameter(command, "RequestTo", DbType.Guid, studentHouseLeave.RequestTo); db.AddInParameter(command, "status", DbType.Int16, studentHouseLeave.status); db.AddOutParameter(command, "RequestDate", DbType.DateTime, 30); if (transaction == null) { db.ExecuteNonQuery(command); } else { db.ExecuteNonQuery(command, transaction); } studentHouseLeave.RequestDate = Convert.ToDateTime(db.GetParameterValue(command, "RequestDate").ToString()); studentHouseLeave.ResponseDate = studentHouseLeave.RequestDate; return(true); }
public bool Insert(StudentHouseLeave studentHouseLeave, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_StudentHouseLeaveInsert"); db.AddInParameter(command, "HouseId", DbType.Guid, studentHouseLeave.HouseId); db.AddInParameter(command, "BaseHouseRoomId", DbType.Guid, studentHouseLeave.BaseHouseRoomId); db.AddInParameter(command, "RequestBy", DbType.Guid, studentHouseLeave.RequestBy); db.AddInParameter(command, "RequestTo", DbType.Guid, studentHouseLeave.RequestTo); db.AddInParameter(command, "status", DbType.Int16, studentHouseLeave.status); db.AddOutParameter(command, "RequestDate", DbType.DateTime, 30); if (transaction == null) { db.ExecuteNonQuery(command); } else { db.ExecuteNonQuery(command, transaction); } studentHouseLeave.RequestDate = Convert.ToDateTime(db.GetParameterValue(command, "RequestDate").ToString()); studentHouseLeave.ResponseDate = studentHouseLeave.RequestDate; return true; }
public static StudentHouseLeave SelectByRoomId(Guid StudentRoomId, Guid RequestTo) { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); studentHouseLeave.BaseHouseRoomId = StudentRoomId; studentHouseLeave.RequestTo = RequestTo; if (!new StudentHouseLeaveDAO().SelectByRoom(studentHouseLeave)) { studentHouseLeave = null; } return studentHouseLeave; }
public bool IsStudentHouseLeaveExist(StudentHouseLeave studentHouseLeave) { Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_StudentHouseLeave_IsExist"); db.AddInParameter(command, "HouseId", DbType.Guid, studentHouseLeave.HouseId); db.AddInParameter(command, "RequestTo", DbType.Guid, studentHouseLeave.RequestTo); db.AddOutParameter(command, "IsExist", DbType.Boolean, 1); db.ExecuteNonQuery(command); return(Convert.ToBoolean(db.GetParameterValue(command, "IsExist").ToString())); }
public bool IsStudentHouseLeaveExist(StudentHouseLeave studentHouseLeave) { Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_StudentHouseLeave_IsExist"); db.AddInParameter(command, "HouseId", DbType.Guid, studentHouseLeave.HouseId); db.AddInParameter(command, "RequestTo", DbType.Guid, studentHouseLeave.RequestTo); db.AddOutParameter(command, "IsExist", DbType.Boolean, 1); db.ExecuteNonQuery(command); return Convert.ToBoolean(db.GetParameterValue(command, "IsExist").ToString()); }
public static StudentHouseLeave SelectByRoomId(Guid StudentRoomId, Guid RequestTo) { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); studentHouseLeave.BaseHouseRoomId = StudentRoomId; studentHouseLeave.RequestTo = RequestTo; if (!new StudentHouseLeaveDAO().SelectByRoom(studentHouseLeave)) { studentHouseLeave = null; } return(studentHouseLeave); }
public void LoadLeaveCurrentRoomRequest(Guid roomId) { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); studentHouseLeave = StudentHouseLeave.SelectByRoomId(roomId, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); if ((studentHouseLeave.RequestBy != null && studentHouseLeave.RequestBy != Guid.Empty) && studentHouseLeave.status == 0) { RHP.UserManagement.User _RequestedUser = RHP.UserManagement.User.Select(studentHouseLeave.RequestBy); RequestedUser.Text = _RequestedUser.FirstName + " " + _RequestedUser.LastName; RequestedUserName.Text = _RequestedUser.FirstName + " " + _RequestedUser.LastName; RequestedUser.NavigateUrl = "~/Student/Student_Public_Profile.aspx?AccessCode=" + studentHouseLeave.RequestBy + "&AccessCode2=" + roomId.ToString(); RespondeToLeaveHouseTrue.Visible = true; } else { RespondeToLeaveHouseFalse.Visible = true; } }
/// <summary> /// Todo /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool SelectByRoom(StudentHouseLeave entity) { bool result = true; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_StudentHouseLeaveSelectByBaseHouseRoomId"); db.AddInParameter(dbCommand, "BaseHouseRoomId", DbType.Guid, entity.BaseHouseRoomId); db.AddInParameter(dbCommand, "RequestTo", DbType.Guid, entity.RequestTo); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { if (entity == null) { entity = new StudentHouseLeave(); } RHP.Utility.Generic.AssignDataReaderToEntity(dataReader, entity); } } return(result); }
public bool SelectByHouse(StudentHouseLeave entity) { bool result = true; Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_StudentHouseLeaveSelect"); db.AddInParameter(dbCommand, "HouseId", DbType.Guid, entity.HouseId); db.AddInParameter(dbCommand, "RequestTo", DbType.Guid, entity.RequestTo); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { if (entity == null) { entity = new StudentHouseLeave(); } RHP.Utility.Generic.AssignDataReaderToEntity(dataReader, entity); } } return result; }
public void LoadLeaveCurrentHouseRequest(Guid HouseId) { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); studentHouseLeave = StudentHouseLeave.SelectByHouseId(HouseId, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); if ((studentHouseLeave.RequestBy != null && studentHouseLeave.RequestBy != Guid.Empty) && studentHouseLeave.status == 0) { RHP.UserManagement.User _RequestedUser = RHP.UserManagement.User.Select(studentHouseLeave.RequestBy); // Photo photo = new Photo(); // RequestedUser.ImageUrl = photo.LoadImage(studentHouseLeave.RequestBy, Enums.PhotoCategory.Profile_Picture); RequestedUser.Text = _RequestedUser.FirstName + " " + _RequestedUser.LastName; RequestedUserName.Text = _RequestedUser.FirstName + " " + _RequestedUser.LastName; RequestedUser.NavigateUrl = "~/Student/Student_Public_Profile.aspx?AccessCode=" + studentHouseLeave.RequestBy; RespondeToLeaveHouseTrue.Visible = true; } else { RespondeToLeaveHouseFalse.Visible = true; } }
public bool Update(StudentHouseLeave studentHouseLeave) { Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); return(this.Update(studentHouseLeave, db, null)); }
public bool Insert(StudentHouseLeave studentHouseLeave) { Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); return this.Insert(studentHouseLeave, db, null); }
protected void RequestLeaveCurrentHouse_Command(object sender, CommandEventArgs args) { string userid = (string)args.CommandArgument; RHP.UserManagement.User _user = new RHP.UserManagement.User(); _user = RHP.UserManagement.User.Select(Guid.Parse(userid)); StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); studentHouseLeave.RequestBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); studentHouseLeave.RequestTo = Guid.Parse(userid); studentHouseLeave.HouseId = _user.HouseId.Value; studentHouseLeave.status = 0; studentHouseLeave.Save(); string strMsgContent = message(_user); string strMsgTitle = "www.ratemystudenthome.com is Requesting you to Leave Current Residence."; int rtn = SendEmail(_user.PersonalEmail, strMsgTitle, strMsgContent); Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.LeaveCurrentHouseRequestSuccess + "'); window.location = '/Student/Student_Profile_Leave_Current_House.aspx';}", true); }
protected void OnConfirmRequest(object sender, EventArgs e) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { user.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); user.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); Guid HouseId = Guid.Empty; Guid RoomId = Guid.Empty; if (user.HouseId.HasValue) { HouseId = user.HouseId.Value; user.HouseId = null; } else if (user.BaseHouseRoomId.HasValue) { RoomId = user.BaseHouseRoomId.Value; user.BaseHouseRoomId = null; } if (user.UpdateHouse()) { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); if (user.HouseId.HasValue) { studentHouseLeave = StudentHouseLeave.SelectByHouseId(HouseId, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); } else if (user.BaseHouseRoomId.HasValue) { studentHouseLeave = StudentHouseLeave.SelectByRoomId(RoomId, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); } studentHouseLeave.status = 1; if (studentHouseLeave.Save()) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.LeaveCurrentHouseResponseSuccess + "'); window.location = '/Student/Student_Profile_Leave_Current_House.aspx';}", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.LeaveCurrentHouseResponseUnSuccess + "'); window.location = '/Student/Student_Profile_Leave_Current_House.aspx';}", true); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.LeaveCurrentHouseResponseUnSuccess + "'); window.location = '/Student/Student_Profile_Leave_Current_House.aspx';}", true); } } else { user.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); if (user.HouseId.HasValue) { studentHouseLeave = StudentHouseLeave.SelectByHouseId(user.HouseId.Value, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); } else if (user.BaseHouseRoomId.HasValue) { studentHouseLeave = StudentHouseLeave.SelectByRoomId(user.BaseHouseRoomId.Value, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); } studentHouseLeave.status = 2; if (studentHouseLeave.Save()) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.RejectLeaveCurrentHouseResponseSuccess + "'); window.location = '/Student/Student_Profile_Leave_Current_House.aspx';}", true); } } }
protected void ItemDataBound(object sender, DataListItemEventArgs e) { Photo photo = new Photo(); HiddenField HiddenField_ = (HiddenField)e.Item.FindControl("hdUserId"); HiddenField hdHouseId_ = (HiddenField)e.Item.FindControl("hdHouseId"); HiddenField hdBaseHouseRoomId_ = (HiddenField)e.Item.FindControl("hdBaseHouseRoomId"); HyperLink Image_ = (HyperLink)e.Item.FindControl("HyperLinkimage"); LinkButton RequestLeaveCurrentHouse_ = (LinkButton)e.Item.FindControl("RequestLeaveCurrentHouse"); Label LabelItsMe_ = (Label)e.Item.FindControl("LabelItsMe"); Image_.ImageUrl = photo.LoadImage(Guid.Parse(HiddenField_.Value.ToString()), Enums.PhotoCategory.Profile_Picture); if (Guid.Parse(HiddenField_.Value) == Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())) { RequestLeaveCurrentHouse_.Visible = false; LabelItsMe_.Visible = true; LabelItsMe_.Text = "It's Me"; } else { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); if (hdHouseId_.Value.Trim() != string.Empty) { studentHouseLeave = StudentHouseLeave.SelectByHouseId(Guid.Parse(hdHouseId_.Value), Guid.Parse(HiddenField_.Value)); } else if (hdBaseHouseRoomId_.Value.Trim() != string.Empty) { studentHouseLeave = StudentHouseLeave.SelectByHouseId(Guid.Parse(hdBaseHouseRoomId_.Value), Guid.Parse(HiddenField_.Value)); } if ((studentHouseLeave.RequestBy != null && studentHouseLeave.RequestBy != Guid.Empty) && studentHouseLeave.status == 0) { if (studentHouseLeave.RequestBy == Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())) { RequestLeaveCurrentHouse_.Visible = false; LabelItsMe_.Visible = true; LabelItsMe_.Text = "Request Already Sent"; } } } }
public void OnConfirm(object sender, EventArgs e) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { user.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); Guid HouseId = Guid.Empty; Guid RoomId = Guid.Empty; if (user.HouseId.HasValue) { HouseId = user.HouseId.Value; user.HouseId = null; } else if (user.BaseHouseRoomId.HasValue) { RoomId = user.BaseHouseRoomId.Value; user.BaseHouseRoomId = null; } if (user.UpdateHouse()) { StudentHouseLeave studentHouseLeave = new StudentHouseLeave(); if (HouseId !=Guid.Empty ) { studentHouseLeave = StudentHouseLeave.SelectByHouseId(HouseId, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); } else if (RoomId != Guid.Empty) { studentHouseLeave = StudentHouseLeave.SelectByRoomId(RoomId, Guid.Parse(Membership.GetUser().ProviderUserKey.ToString())); } studentHouseLeave.status = 1; if (studentHouseLeave.Save()) { } Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Delete_success + "'); window.location = '/Student/Student_Profile.aspx';}", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Delete_Unsuccess + "'); window.location = '/Student/Student_Profile.aspx';}", true); } } else { // this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true); } }