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; } }
/// <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) { } }
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; } }