protected void InsertButton_Click(object sender, EventArgs e) { try { using (TopCareDataContext db = new TopCareDataContext()) { MemberSubscriptionsPaid _tempMemberSubscriptionsPaid = new MemberSubscriptionsPaid(); _tempMemberSubscriptionsPaid.MemberID = Convert.ToInt32(Request.QueryString["mid"]); _tempMemberSubscriptionsPaid.AmountPaid = Convert.ToDecimal(AmountPaidTextBox.Text.Trim()); // _tempMemberSubscriptionsPaid.CreatedBy = Session["CurrentUser"].ToString(); _tempMemberSubscriptionsPaid.CreatedDate = DateTime.Now; _tempMemberSubscriptionsPaid.ExpiryDate = Convert.ToDateTime(PaymentDateTextBox.Text.Trim()).AddYears(1).AddDays(-1); _tempMemberSubscriptionsPaid.PaymentDate = Convert.ToDateTime(PaymentDateTextBox.Text.Trim()); // _tempMemberSubscriptionsPaid.PaymentRecievedBy = Session["CurrentUser"].ToString(); db.MemberSubscriptionsPaids.InsertOnSubmit(_tempMemberSubscriptionsPaid); db.SubmitChanges(); GridView1.DataBind(); } } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Schedule _schedule; using (TopCareDataContext db = new TopCareDataContext()) { _schedule = db.Schedules.FirstOrDefault(s => s.ScheduleID == Convert.ToInt32(Request.QueryString["sID"])); if (_schedule != null) { //set header - schedule date headerHyperLink.Text = _schedule.DateOfEvent.Value.ToString("dd-MMM-yyyy"); headerHyperLink.NavigateUrl = String.Format("NewSchedule.aspx?sID={0}", Request.QueryString["sID"]); if (_schedule.ScheduleDetails.Count == 0) //schedule without details { LoadTimesFromTemplate(); } else //load details from database { LoadScheduleDetailsFromDatabase(_schedule); } } } } }
protected void Page_Load(object sender, EventArgs e) { //TopCareDataContext db = new TopCareDataContext(); TopCareDataContext db = new TopCareDataContext(); int daysToBirthday = 5; var birthdayCelebrants = db.Members.Where(m => (DateTime.Today - m.DOB.Value).Days == daysToBirthday); //get all celebrants who fall into the criteria Repeater1.DataSource = BirthdayCelebrant.GenerateBirthdayCelebrants(birthdayCelebrants.ToList<Member>()); Repeater1.DataBind(); }
protected void LinkButton1_Click(object sender, EventArgs e) { amountPaid = Convert.ToDecimal(TextBox2.Text); //create data context for data entry TopCareDataContext db = new TopCareDataContext(); foreach (ListItem item in CheckBoxList1.Items) { if (item.Selected) { int scheduleId = Convert.ToInt32( item.Value); PayforSchedule(scheduleId, db); } } Response.Redirect(Request.RawUrl); }
//load template items void LoadTimesFromTemplate() { List<TimeTemplateItem> _tempListItems = new List<TimeTemplateItem>(); using (TopCareDataContext db = new TopCareDataContext()) { foreach (ProgrameTimeTemplate templateItem in db.ProgrameTimeTemplates) { _tempListItems.Add(new TimeTemplateItem() { StartTime = templateItem.StartTime.Value.ToString(), EndTime = templateItem.EndTime.Value.ToString(), Item = templateItem.Template }); } } GridView1.DataSource = _tempListItems; GridView1.DataBind(); }
/// <summary> /// This method inserts payment for a particular schdule with an amount thats supplied. /// It returns the remainder after the schedule amount due is subtructed. /// </summary> /// <param name="scheduleID"></param> /// <returns></returns> void PayforSchedule(int scheduleID, TopCareDataContext db) { Schedule _schedule = db.Schedules.FirstOrDefault(s => s.ScheduleID == scheduleID); if (amountPaid >= _schedule.PaymentExpected) { MemberAttendance memberAttendance = new MemberAttendance(); memberAttendance.ScheduleID = scheduleID; memberAttendance.AmountPaid = _schedule.PaymentExpected; memberAttendance.HasPaid = true; memberAttendance.IsFeeWaived = false; memberAttendance.MemberID = Convert.ToInt32(Request.QueryString["mid"]); memberAttendance.PaymentDate = DateTime.Now; memberAttendance.PaymentRecievedBy = HttpContext.Current.User.Identity.Name; db.MemberAttendances.InsertOnSubmit(memberAttendance); db.SubmitChanges(); amountPaid = amountPaid - _schedule.PaymentExpected.Value; } }
//load template items void LoadTimesFromTemplate(bool deleteScheduleDetails) { List<TimeTemplateItem> _tempListItems = new List<TimeTemplateItem>(); using (TopCareDataContext db = new TopCareDataContext()) { foreach (ProgrameTimeTemplate templateItem in db.ProgrameTimeTemplates) { _tempListItems.Add(new TimeTemplateItem() { StartTime = templateItem.StartTime.Value.ToString(), EndTime = templateItem.EndTime.Value.ToString(), Item = templateItem.Template }); } if (deleteScheduleDetails) { db.Schedules.FirstOrDefault(s => s.ScheduleID == Convert.ToInt32(Request.QueryString["sID"])).ScheduleDetails.Clear(); db.SubmitChanges(); } } GridView1.DataSource = _tempListItems; GridView1.DataBind(); }
void save() { TopCareDataContext db = new TopCareDataContext(); Schedule _schedule = db.Schedules.FirstOrDefault(s => s.ScheduleID == Convert.ToInt32(Request.QueryString["sID"])); // List<ScheduleDetail> _scheduleLists = new List<ScheduleDetail>(); TimeSpan _tempStartTimeStamp; TimeSpan _tempEndTimeStamp; foreach (GridViewRow item in GridView1.Rows) { if (item.RowType == DataControlRowType.DataRow) { TextBox _txtStartTime = item.FindControl("txtStartTime") as TextBox; TextBox _txtEndTime = item.FindControl("txtEndTime") as TextBox; TextBox _textBox2 = item.FindControl("TextBox2") as TextBox; HiddenField _hiddenField = item.FindControl("HiddenField1") as HiddenField; TimeSpan.TryParse(_txtStartTime.Text, out _tempStartTimeStamp); TimeSpan.TryParse(_txtEndTime.Text, out _tempEndTimeStamp); if (_hiddenField.Value.Length == 0) //schedule has no items add all template items { _schedule.ScheduleDetails.Add(new ScheduleDetail() { EndTime = _tempEndTimeStamp, Item = _textBox2.Text, StartTime = _tempStartTimeStamp }); } else { ScheduleDetail _tempScheduleDetail = _schedule.ScheduleDetails.FirstOrDefault(s => s.ScheduleDetailID == Convert.ToInt32(_hiddenField.Value)); _tempScheduleDetail.StartTime = _tempStartTimeStamp; _tempScheduleDetail.EndTime = _tempEndTimeStamp; _tempScheduleDetail.Item = _textBox2.Text; } } } db.SubmitChanges(); }
/// <summary> /// Save RSVP details /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { using (TopCareDataContext db = new TopCareDataContext()) { PreScheduleFollowup tempPrescheduleFollowUp = db.PreScheduleFollowups.FirstOrDefault(p => p.ScheduleID == ScheduleID); if (tempPrescheduleFollowUp == null) { tempPrescheduleFollowUp = new PreScheduleFollowup() { DateCreated = DateTime.Now, ScheduleID = ScheduleID, CreatedBy = User.Identity.Name, FollowupDoneBy = User.Identity.Name }; //insert into database. Treat it as a new record. db.PreScheduleFollowups.InsertOnSubmit(tempPrescheduleFollowUp); } else //jst set modified fields { tempPrescheduleFollowUp.ModifiedBy = User.Identity.Name; tempPrescheduleFollowUp.ModifiedDate = DateTime.Now; //tempPrescheduleFollowUp.FollowupDoneBy = } foreach (GridViewRow item in GridView1.Rows) { if (item.RowType == DataControlRowType.DataRow) { PreScheduleFollowupDetail tempPreScheduleFollowupDetail; UserControls.RSVPWebUserControl usrControl = item.FindControl("RSVPWebUserControl1") as UserControls.RSVPWebUserControl; TextBox txtComments = item.FindControl("TextBox3") as TextBox; vwPreScheduleFollowup temDataItem = new vwPreScheduleFollowup() { DropOffTime = usrControl.Dropoff, Comments = (item.FindControl("TextBox3") as TextBox).Text, MemberID = usrControl.MemberID.Value, PickOffTime = usrControl.Pickup, RSVPStatusID = Convert.ToInt32((item.FindControl("DropDownList2") as DropDownList).SelectedValue), PreScheduleFollowupDetailID = usrControl.PreScheduleFollowupDetailID, IsTransportBooked = usrControl.IsTransportBooked }; if (tempPrescheduleFollowUp.PreScheduleFollowupID > 0) //already in the database { tempPreScheduleFollowupDetail = tempPrescheduleFollowUp.PreScheduleFollowupDetails.FirstOrDefault(d => d.PreScheduleFollowupDetailID == temDataItem.PreScheduleFollowupDetailID); if (tempPreScheduleFollowupDetail != null) { tempPreScheduleFollowupDetail.Comments = temDataItem.Comments; tempPreScheduleFollowupDetail.DropOffTime = temDataItem.DropOffTime; tempPreScheduleFollowupDetail.PickOffTime = temDataItem.PickOffTime; tempPreScheduleFollowupDetail.RSVPStatusID = temDataItem.RSVPStatusID; tempPreScheduleFollowupDetail.IsTransportBooked = temDataItem.IsTransportBooked; } else { tempPreScheduleFollowupDetail = new PreScheduleFollowupDetail(); tempPreScheduleFollowupDetail.Comments = temDataItem.Comments; tempPreScheduleFollowupDetail.DropOffTime = temDataItem.DropOffTime; tempPreScheduleFollowupDetail.PickOffTime = temDataItem.PickOffTime; tempPreScheduleFollowupDetail.RSVPStatusID = temDataItem.RSVPStatusID; tempPreScheduleFollowupDetail.MemberID = temDataItem.MemberID; tempPreScheduleFollowupDetail.IsTransportBooked = temDataItem.IsTransportBooked; //tempPreScheduleFollowupDetail.TransportArrangementStatusID = temDataItem.Transpo; //add detail to header tempPrescheduleFollowUp.PreScheduleFollowupDetails.Add(tempPreScheduleFollowupDetail); } } else { tempPreScheduleFollowupDetail = new PreScheduleFollowupDetail(); tempPreScheduleFollowupDetail.Comments = temDataItem.Comments; tempPreScheduleFollowupDetail.DropOffTime = temDataItem.DropOffTime; tempPreScheduleFollowupDetail.PickOffTime = temDataItem.PickOffTime; tempPreScheduleFollowupDetail.RSVPStatusID = temDataItem.RSVPStatusID; tempPreScheduleFollowupDetail.MemberID = temDataItem.MemberID; tempPreScheduleFollowupDetail.IsTransportBooked = temDataItem.IsTransportBooked; //add detail to header tempPrescheduleFollowUp.PreScheduleFollowupDetails.Add(tempPreScheduleFollowupDetail); } //CheckBox chkBox = item.FindControl("CheckBox1") as CheckBox; //UserControls.RSVPWebUserControl usrControl = item.FindControl("AttendanceWebUserControl1") as UserControls.RSVPWebUserControl; db.SubmitChanges(); } } } Response.Redirect("~//topcare//ReportPages//PreScheduleFollowupSummary.aspx?sID=" + Request.QueryString["sID"]); } catch (Exception) { } }
PreScheduleFollowupDetail GetPreScheduleFollowupDetail(int scheduleID, int MemberID, TopCareDataContext db) { try { var result = db.PreScheduleFollowups.FirstOrDefault(p => p.ScheduleID == scheduleID).PreScheduleFollowupDetails.FirstOrDefault(pd => pd.MemberID == MemberID); if (result == null) { return null; } else { return result; } } catch (Exception) { return null; } }
decimal AmountPaidByMemberForSchedule() { try { using (TopCareDataContext db = new TopCareDataContext()) { MemberAttendance mAttendace = db.MemberAttendances.FirstOrDefault(m => m.MemberID == MemberID && m.ScheduleID == ScheduleID); if (mAttendace != null) { //assiging the MemberAttendanceID MemberAttendanceID = mAttendace.MemberAttendanceID; if (mAttendace.AmountPaid.Value > 0) { return mAttendace.AmountPaid.Value; } else if (mAttendace.IsFeeWaived.Value) { return -50000; } else { return 0; } } else { return 0; } } } catch (Exception) { return 0; } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["sID"] != null) { if (!IsPostBack) { using (TopCareDataContext db = new TopCareDataContext()) { int SchdeuleID; int.TryParse(Request.QueryString["sID"], out SchdeuleID); //var tempList = db.vwMemberAttendances.Where(s => s.ScheduleID == SchdeuleID); lblTitle.Text += " "+ db.Schedules.FirstOrDefault(s => s.ScheduleID == SchdeuleID).DateOfEvent.Value .ToShortDateString(); Session["TempvwMemberAttendance"] = GetVwMemberAttendance(db); GridView1.DataSource = Session["TempvwMemberAttendance"]; GridView1.DataBind(); } } } }
protected void btnSave_Click(object sender, EventArgs e) { //GridView1.Rows try { MemberAttendance tempMA; using (TopCareDataContext db = new TopCareDataContext()) { foreach (GridViewRow item in GridView1.Rows) { if (item.RowType == DataControlRowType.DataRow) { CheckBox chkBox = item.FindControl("CheckBox1") as CheckBox; UserControls.AttendanceWebUserControl usrControl = item.FindControl("AttendanceWebUserControl1") as UserControls.AttendanceWebUserControl; UserControls.SubscriptionFeeWebUserControl usrControl2 = item.FindControl("SubscriptionFeeWebUserControl1") as UserControls.SubscriptionFeeWebUserControl; decimal d = usrControl.PaidAmount; tempMA = db.MemberAttendances.FirstOrDefault(m => m.MemberID == usrControl.MemberID && m.ScheduleID == usrControl.ScheduleID); //if payment for subscription is made, save it in the database if (usrControl2.PaidAmount > 0) { MemberSubscriptionsPaid _memberSubscriptionsPaid = new MemberSubscriptionsPaid(); _memberSubscriptionsPaid.AmountPaid = usrControl2.PaidAmount; _memberSubscriptionsPaid.CreatedBy = HttpContext.Current.User.Identity.Name; _memberSubscriptionsPaid.CreatedDate = DateTime.Now; _memberSubscriptionsPaid.ExpiryDate = DateTime.Today.AddYears(1).AddDays(-1); _memberSubscriptionsPaid.IsWaived = usrControl2.IsWaived; _memberSubscriptionsPaid.MemberID = usrControl2.MemberID; _memberSubscriptionsPaid.PaymentDate = DateTime.Now; _memberSubscriptionsPaid.PaymentRecievedBy = HttpContext.Current.User.Identity.Name; db.MemberSubscriptionsPaids.InsertOnSubmit(_memberSubscriptionsPaid); } if (tempMA != null) { tempMA.HasAttended = chkBox.Checked; tempMA.IsFeeWaived = usrControl.IsWaived; tempMA.AmountPaid = usrControl.PaidAmount; //db.SubmitChanges(); } else { tempMA = new MemberAttendance(); tempMA.HasAttended = chkBox.Checked; tempMA.IsFeeWaived = usrControl.IsWaived; tempMA.PaymentDate = DateTime.Now; tempMA.AmountPaid = usrControl.PaidAmount; tempMA.MemberID = usrControl.MemberID; tempMA.ScheduleID = usrControl.ScheduleID; tempMA.PaymentRecievedBy = HttpContext.Current.User.Identity.Name; db.MemberAttendances.InsertOnSubmit(tempMA); } db.SubmitChanges(); } } } //Response.Redirect("ScheduleList_MultiView.aspx"); Response.Redirect("~/topcare/ReportPages/SchAttendanceSummary.aspx?sID=" + Request.QueryString["sID"]); } catch (Exception) { throw; } }
List<vwMemberAttendance> GetVwMemberAttendance(TopCareDataContext db) { int ScheduleID = Convert.ToInt32(Request.QueryString["sID"]); List<vwMemberAttendance> temp = new List<vwMemberAttendance>(); vwMemberAttendance _tempMAToAdd; foreach (Member memberItem in db.Members) { _tempMAToAdd = new vwMemberAttendance(); var _tempMA = memberItem.MemberAttendances.OrderBy(o => o.Member.FirstName).OrderBy(l => l.Member.LastName).FirstOrDefault(t => t.ScheduleID == ScheduleID); if (_tempMA == null) { _tempMAToAdd.HasPaid = false; _tempMAToAdd.AmountPaid = 0; _tempMAToAdd.HasAttended = false; } else { _tempMAToAdd.HasPaid = true; _tempMAToAdd.AmountPaid = _tempMA.AmountPaid; _tempMAToAdd.HasAttended = _tempMA.HasAttended; _tempMAToAdd.IsFeeWaived = _tempMA.IsFeeWaived; } _tempMAToAdd.FirstName = memberItem.FirstName; _tempMAToAdd.HasAttended = _tempMAToAdd.HasAttended.HasValue ? _tempMAToAdd.HasAttended : false; //_tempMAToAdd.IsFeeWaived = false; _tempMAToAdd.LastName = memberItem.LastName; _tempMAToAdd.MemberID = memberItem.MemberID; _tempMAToAdd.ScheduleID = ScheduleID; _tempMAToAdd.IsSubscriptionPaid = Utils.IsSubsrciptionPaid(memberItem.MemberID) ? 0 : 1; temp.Add(_tempMAToAdd); } return temp; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //clsScheduleDetailsForAttach scheduleReportForAttach = new clsScheduleDetailsForAttach(Convert.ToInt32(Request.QueryString["sID"])); //MyAttachement = GetReportAttachement(); TopCareDataContext db = new TopCareDataContext(); MySchedule = db.Schedules.FirstOrDefault(sch => sch.ScheduleID == scheduleID); lblAttachedFile.Text = String.Format("Charisma Programe Outline-{0}.pdf", MySchedule.DateOfEvent.Value.ToShortDateString()); txtSubject.Text = String.Format("Charisma Programe Outline for {0}", MySchedule.DateOfEvent.Value.ToShortDateString()); txtRecipients.Text = GetRecipients(); } }
string GetRecipients() { string recipients = ""; TopCareDataContext db = new TopCareDataContext(); foreach (DBSSTaff item in db.DBSSTaffs.Where(s => s.EmailAddress.Length > 0 )) { recipients += item.FirstName + " " + item.LastName + "<" + item.EmailAddress + ">;"; } return recipients; }
List<vwPreScheduleFollowup> GetMemberList(int? transportOptionID ) { List<vwPreScheduleFollowup> _tempVwPreScheduleFollowup = new List<vwPreScheduleFollowup>(); using (TopCareDataContext db = new TopCareDataContext()) { IQueryable<Member> _tempMembersList; //select all members if [all] is selected if (transportOptionID == null) { _tempMembersList = db.Members; } else //filter by transport option if selected { _tempMembersList = db.Members.Where<Member>(m => m.TransportationOptionID == transportOptionID); } foreach (Member memberItem in _tempMembersList) { var tempPreScheduleFollowupDetail = GetPreScheduleFollowupDetail(Convert.ToInt32(Request.QueryString["sID"]), memberItem.MemberID, db); string clientNumbers = ""; if ((memberItem.PhoneNumber1 ?? "").Length > 0) { clientNumbers += memberItem.PhoneNumber1; } if ((memberItem.PhoneNumber2 ?? "").Length > 0) { clientNumbers += ", " + memberItem.PhoneNumber2; } if ((memberItem.PhoneNumber3 ?? "").Length > 0) { clientNumbers += ", " + memberItem.PhoneNumber3; } if (tempPreScheduleFollowupDetail == null) { //var x = memberItem.PhoneNumber1 + memberItem.PhoneNumber2 == null ? memberItem.PhoneNumber3 == null ? "" : memberItem.PhoneNumber2 : memberItem.PhoneNumber3; _tempVwPreScheduleFollowup.Add(new vwPreScheduleFollowup() { IsTransportBooked = false, MemberID = memberItem.MemberID, Name = memberItem.FirstName + " " + memberItem.LastName, PhoneNumber1 = clientNumbers, MemberTransportationID = memberItem.MemberTransportationID, RSVPStatusID = 4 /*4 is the default stands for Not called*/ }); } else { _tempVwPreScheduleFollowup.Add(new vwPreScheduleFollowup() { Comments = tempPreScheduleFollowupDetail.Comments, DropOffTime = tempPreScheduleFollowupDetail.DropOffTime, IsTransportBooked = tempPreScheduleFollowupDetail.IsTransportBooked, Name = memberItem.FirstName + " " + memberItem.LastName, RSVPStatusID = tempPreScheduleFollowupDetail.RSVPStatusID, MemberID = tempPreScheduleFollowupDetail.MemberID.Value, PickOffTime = tempPreScheduleFollowupDetail.PickOffTime, PreScheduleFollowupDetailID = tempPreScheduleFollowupDetail.PreScheduleFollowupDetailID, PreScheduleFollowupID = tempPreScheduleFollowupDetail.PreScheduleFollowupID.Value, PhoneNumber1 = clientNumbers, MemberTransportationID = memberItem.MemberTransportationID }); } } return _tempVwPreScheduleFollowup; } }