public int CreateMemberAttendance(MemberAttendance mat) { try { SqlParameter[] m = new SqlParameter[15]; m[0] = new SqlParameter("@Id", SqlDbType.Int); m[1] = new SqlParameter("@AttendanceDate", mat.AttendanceDate); m[2] = new SqlParameter("@UserID", mat.UserID); m[3] = new SqlParameter("@AttendanceStatus", mat.AttendanceStatus); m[4] = new SqlParameter("@CreateDate", mat.CreateDate); m[5] = new SqlParameter("@UDF1", mat.UDF1); m[6] = new SqlParameter("@UDF2", mat.UDF2); m[7] = new SqlParameter("@UDF3", mat.UDF3); m[8] = new SqlParameter("@GroupID", mat.GroupID); m[9] = new SqlParameter("@AttendanceTime", mat.AttendanceTime); m[10] = new SqlParameter("@Device", mat.Device); m[11] = new SqlParameter("@DeviceIDOrName", mat.DeviceIDOrName); m[12] = new SqlParameter("@DeviceLocation", mat.DeviceLocation); m[13] = new SqlParameter("@Session", mat.Session); m[14] = new SqlParameter("@ClientID", mat.ClientID); m[0].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(Connection.Connection_string, CommandType.StoredProcedure, "Attendance_Insert", m); object ivalue = m[0].Value; return((int)ivalue); } catch (Exception ex) { throw ex; } }
private List <MemberAttendance> NoShowList(DateTime dFrom, DateTime dTo) { var gymMemberAttendanceList = new List <MemberAttendance>(); var noShows = db.MemberClassBookings.Where(bk => !bk.Attended && !bk.Waiting && bk.GymClass.ClassDateTime >= dFrom && bk.GymClass.ClassDateTime <= dTo) .OrderBy(bk => bk.GymMemberId).ToList(); MemberAttendance currentMemberAttendance = new MemberAttendance(); foreach (var noShow in noShows) { if (currentMemberAttendance.Member != null && noShow.GymMemberId == currentMemberAttendance.Member.GymMemberId) { currentMemberAttendance.NoShows++; } else { if (currentMemberAttendance.Member != null) { gymMemberAttendanceList.Add(currentMemberAttendance); } currentMemberAttendance = new MemberAttendance(); currentMemberAttendance.Member = db.GymMembers.Find(noShow.GymMemberId); currentMemberAttendance.NoShows = 1; } } if (currentMemberAttendance.NoShows > 0) { gymMemberAttendanceList.Add(currentMemberAttendance); } return(gymMemberAttendanceList.OrderByDescending(ma => ma.NoShows).OrderBy(ma => ma.Member.LastName).ToList()); }
protected void btnSendAttendanceMail_Click(object sender, EventArgs e) { try { DateTime AttendanceDate = DateTime.UtcNow.AddHours(5.5).Date; User member = new UserController().GetUser(Context.User.Identity.Name); MemberAttendance ma = new MemberAttendance(); ma.AttendanceDate = AttendanceDate; int AttendanceCount = Convert.ToInt32(litAttCount.Text); if (AttendanceCount % 2 == 0) { ma.AttendanceStatus = "Checkin"; } else { ma.AttendanceStatus = "Checkout"; } ma.AttendanceTime = DateTime.UtcNow.AddHours(5.5).ToShortTimeString(); ma.ClientID = member.ClientID; ma.CreateDate = DateTime.UtcNow.AddHours(5.5); ma.Device = "Web"; ma.DeviceIDOrName = string.Empty; ma.DeviceLocation = txtLatLong.Text; ma.GroupID = GroupID; ma.Session = General.GetCurrentSession; ma.UDF1 = "0"; ma.UDF2 = member.FirstName; ma.UDF3 = "Self"; ma.UserID = member.UserID; string DeviceIDOrName = string.Empty; try { DeviceIDOrName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_HOST"]).HostName; } catch { } new AttendanceController().CreateMemberAttendance(ma); // new AttendanceController().UpdateMemberAttendance(u.UserID, GroupID, DateTime.UtcNow.AddHours(5.5).Date, "Present", 1, DateTime.UtcNow.AddHours(5.5).ToShortTimeString(),"Web",DeviceIDOrName,txtLatLong.Text,"Self"); General.ShowAlertMessage("Thank you! Your " + btnSendAttendanceMail.Text + " is successfull."); lblError.Text = "Thank you! Your " + btnSendAttendanceMail.Text + " is successfull."; lblError.ForeColor = System.Drawing.Color.Green; AttendanceCount++; litAttCount.Text = AttendanceCount.ToString(); CreateSetup(GroupID, member); } catch (Exception ex) { lblError.Text = "Something is not right, Please try again later!"; General.ShowAlertMessage("Something is not right, Please try again later!"); } }
protected void btnSendAttendanceMail_Click(object sender, EventArgs e) { try { DateTime AttendanceDate = DateTime.UtcNow.AddHours(5.5).Date; int AttChk = new AttendanceController().CheckMemberAttendance(GroupID, AttendanceDate); if (AttChk == 0) { IList <User> Members = new UserController().GetUserListGroup(GroupID); if (Members.Count > 0) { foreach (User member in Members) { MemberAttendance ma = new MemberAttendance(); ma.AttendanceDate = AttendanceDate; ma.AttendanceStatus = "Absent"; ma.AttendanceTime = DateTime.UtcNow.AddHours(5.5).ToShortTimeString(); ma.ClientID = member.ClientID; ma.CreateDate = DateTime.UtcNow.AddHours(5.5); ma.Device = "Web"; ma.DeviceIDOrName = string.Empty; ma.DeviceLocation = txtLatLong.Text; ma.GroupID = GroupID; ma.Session = General.GetCurrentSession; ma.UDF1 = "0"; ma.UDF2 = member.FirstName; ma.UDF3 = "Admin"; ma.UserID = member.UserID; new AttendanceController().CreateMemberAttendance(ma); } } } User u = new UserController().GetUser(Context.User.Identity.Name); string DeviceIDOrName = string.Empty; try { DeviceIDOrName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_HOST"]).HostName; } catch { } new AttendanceController().UpdateMemberAttendance(u.UserID, GroupID, DateTime.UtcNow.AddHours(5.5).Date, "Present", 1, DateTime.UtcNow.AddHours(5.5).ToShortTimeString(), "Web", DeviceIDOrName, txtLatLong.Text, "Self"); General.ShowAlertMessage("Thank you!\r\n Your attendance is saved."); lblError.Text = "Thank you! Your attendance is saved."; lblError.ForeColor = System.Drawing.Color.Green; btnSendAttendanceMail.Visible = false; btnSendAttendanceMail.Enabled = false; } catch (Exception ex) { lblError.Text = "Something is not right, Please try again later!"; General.ShowAlertMessage("Something is not right, Please try again later!"); } }
public ActionResult Create(MemberAttendance memberattendance) { if (ModelState.IsValid) { memberattendance.Id = Guid.NewGuid(); db.MemberAttendances.Add(memberattendance); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.MemberId = new SelectList(db.Members, "Id", "FirstName", memberattendance.MemberId); return View(memberattendance); }
/// <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; } }
// PUT api/MemberAttendance/5 public HttpResponseMessage PutMemberAttendance(Guid id, MemberAttendance memberattendance) { if (ModelState.IsValid && id == memberattendance.Id) { db.Entry(memberattendance).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
// POST api/MemberAttendance public HttpResponseMessage PostMemberAttendance(MemberAttendance memberattendance) { if (ModelState.IsValid) { db.MemberAttendances.Add(memberattendance); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, memberattendance); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = memberattendance.Id })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
private void bindGvContacts() { User u = new UserController().GetUser(Context.User.Identity.Name); IList <User> AdminList = new UserController().GetGroupAdmins(GroupID); IList <User> userList = new UserController().GetUserListGroup(GroupID); //gvContacts.DataSource = userList.Where(ss => ss.UserID != Context.User.Identity.Name); //gvContacts.DataBind(); btnSendAttendanceMail.Visible = false; if (userList.Count > 0) { // btnDeleteRecord.Visible = true; btnSendAttendanceMail.Visible = true; } IList <MemberAttendance> chkAtt = new AttendanceController().GetMemberAttendances(GroupID, DateTime.UtcNow.AddHours(5.5).Date); if (chkAtt.Where(ss => ss.UDF1 == "1").ToList().Count > 0 || chkAtt.Where(ss => ss.UDF1 == "0").ToList().Count > 0) { litAtt.Text = "1"; } if (chkAtt.Where(ss => ss.UDF1 == "2").ToList().Count > 0) { litAtt.Text = "2"; } if (userList.Count < 300 && isAdmin == true && litAtt.Text != "2") { var Students = userList.Where(o => !AdminList.Any(n => n.UserID == o.UserID)).ToList(); gvAttendance.DataSource = Students;// userList.Where(ss => ss.UserID != Context.User.Identity.Name);//.Where(ss => ss.IsLockedOut == false); gvAttendance.DataBind(); gvAttendance.Visible = true; btnSendAttendanceMail.Visible = true; if (userList.Count > 10) { pnlAttendance.Height = Unit.Pixel(510); pnlAttendance.ScrollBars = ScrollBars.Vertical; } } //Insert default attendance as false //int chkAtt = new AttendanceController().CheckMemberAttendance(GroupID, DateTime.Now.Date); if (litAtt.Text == string.Empty) { foreach (GridViewRow grow in gvAttendance.Rows) { CheckBox rbPresent = (CheckBox)grow.FindControl("rbPresent"); CheckBox rbAbsent = (CheckBox)grow.FindControl("rbAbsent"); Label lblName = (Label)grow.FindControl("lblName"); Label lblUserId = (Label)grow.FindControl("UserID"); string Chkattend = string.Empty; string ChkattendForEmail = string.Empty; Chkattend = "Absent"; MemberAttendance objMat = new MemberAttendance(); objMat.UserID = lblUserId.Text; objMat.GroupID = GroupID; objMat.AttendanceStatus = Chkattend; objMat.UDF2 = lblName.Text; objMat.UDF3 = u.FirstName; objMat.AttendanceDate = DateTime.UtcNow.AddHours(5.5).Date; objMat.CreateDate = DateTime.UtcNow.AddHours(5.5); objMat.AttendanceTime = DateTime.UtcNow.AddHours(5.5).ToShortTimeString(); objMat.Device = "Web"; objMat.Session = General.GetCurrentSession; objMat.DeviceLocation = txtLatLong.Text; objMat.DeviceIDOrName = string.Empty; try { objMat.DeviceIDOrName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_HOST"]).HostName; objMat.DeviceLocation = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName; } catch { } if (litAtt.Text == string.Empty) { objMat.UDF1 = "0"; } if (litAtt.Text == "1") { objMat.UDF1 = "2"; } objMat.ClientID = u.ClientID; new AttendanceController().CreateMemberAttendance(objMat); } } else if (litAtt.Text == "1") { IList <MemberAttendance> PresentList = chkAtt.Where(ss => ss.AttendanceStatus == "Present").ToList(); foreach (GridViewRow grow in gvAttendance.Rows) { CheckBox rbPresent = (CheckBox)grow.FindControl("rbPresent"); CheckBox rbAbsent = (CheckBox)grow.FindControl("rbAbsent"); Label lblUserId = (Label)grow.FindControl("UserID"); MemberAttendance a = PresentList.Where(ss => ss.UserID == lblUserId.Text).FirstOrDefault(); if (a != null) { if (a.AttendanceStatus == "Present") { rbPresent.Checked = true; rbAbsent.Checked = false; } } } } else { lblError.Text = "Not valid!"; gvAttendance.Visible = false; btnSendAttendanceMail.Visible = false; } }
public int CreateMemberAttendance(MemberAttendance _MemberAttendance) { return(DataAccess.MemberAttendanceDao.CreateMemberAttendance(_MemberAttendance)); }
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; } }
//private void bindGvAttendaneByDate() //{ // IList<MemberAttendance> chkAtt = new AttendanceController().GetMemberAttendances(GroupID, DateTime.Now.Date); // gvGroupAttendance.DataSource = chkAtt; // gvGroupAttendance.DataBind(); //} //private void HandleButtonEnable() //{ // btnSendAttendanceMail.Enabled = (button1ClickAt == null || button1ClickAt.Value.Date != DateTime.Now.Date); //} protected void btnSendAttendanceMail_Click(object sender, EventArgs e) { try { System.Text.StringBuilder AttendanceSummery = new System.Text.StringBuilder(); AttendanceSummery.Append(string.Empty); IList <MemberAttendance> chkAtt = new AttendanceController().GetMemberAttendances(GroupID, DateTime.Now.Date); if (chkAtt.Where(ss => ss.UDF1 == "1").ToList().Count > 0) { litAtt.Text = "1"; } if (chkAtt.Where(ss => ss.UDF1 == "2").ToList().Count > 0) { litAtt.Text = "2"; } User u = new UserController().GetUser(Context.User.Identity.Name); if (litAtt.Text != "2") { int totalPresent = 0; foreach (GridViewRow grow in gvAttendance.Rows) { CheckBox rbPresent = (CheckBox)grow.FindControl("rbPresent"); CheckBox rbAbsent = (CheckBox)grow.FindControl("rbAbsent"); Label lblName = (Label)grow.FindControl("lblName"); Label lblMobile = (Label)grow.FindControl("Mobile"); Label lblUserId = (Label)grow.FindControl("UserID"); string Chkattend = string.Empty; string ChkattendForEmail = string.Empty; if (rbPresent.Checked) { //string messageBody = "Dear " + grow.Cells[1].Text + ", <br/> Your attendance status for the date " + DateTime.Now.ToShortDateString() + " is Present."; //string EmailBody = "Dear " + grow.Cells[1].Text + ", <br/> Your attendance status for the date " + DateTime.Now.ToShortDateString() + " is Present."; //General.SendSMS(lblMobile.Text, messageBody); //General.SendEmail(lblEmail.Text, "Attendance for Today", EmailBody); Chkattend = "Present"; ChkattendForEmail = "Present"; totalPresent++; } else if (rbAbsent.Checked) { //string messageBody = "Dear " + grow.Cells[1].Text + ", <br/> Your attendance status for the date " + DateTime.Now.ToShortDateString() + " is Absent."; //string EmailBody = "Dear " + grow.Cells[1].Text + ", <br/> Your attendance status for the date " + DateTime.Now.ToShortDateString() + " is Absent."; //General.SendSMS(lblMobile.Text, messageBody); // General.SendEmail(lblEmail.Text, "Attendance for Today", EmailBody); Chkattend = "Absent"; ChkattendForEmail = "<b>Absent</b>"; } MemberAttendance objMat = new MemberAttendance(); objMat.UserID = lblUserId.Text; objMat.GroupID = GroupID; objMat.AttendanceStatus = Chkattend; objMat.UDF2 = lblName.Text; objMat.UDF3 = u.FirstName; objMat.AttendanceDate = DateTime.UtcNow.AddHours(5.5).Date; objMat.CreateDate = DateTime.UtcNow.AddHours(5.5); objMat.AttendanceTime = DateTime.UtcNow.AddHours(5.5).ToShortTimeString(); objMat.Device = "Web"; objMat.Session = General.GetCurrentSession; objMat.DeviceLocation = txtLatLong.Text; try { objMat.DeviceIDOrName = System.Environment.MachineName;// Dns.GetHostEntry(Request.ServerVariables["REMOTE_HOST"]).HostName; } catch (Exception ex) { objMat.DeviceIDOrName = "Error" + ex.Message; } // objMat.DeviceLocation = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName; objMat.UDF1 = "2"; objMat.ClientID = u.ClientID; new AttendanceController().CreateMemberAttendance(objMat); } General.ShowAlertMessage("Attendance Status Send"); } else { lblError.Text = "Not valid!"; gvAttendance.Visible = false; btnSendAttendanceMail.Visible = false; } } catch (Exception ex) { General.ShowAlertMessage("Something is not right, Please try again later!"); } }
public ActionResult Edit(MemberAttendance memberattendance) { if (ModelState.IsValid) { db.Entry(memberattendance).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.MemberId = new SelectList(db.Members, "Id", "FirstName", memberattendance.MemberId); return View(memberattendance); }