public async Task <IActionResult> Create([Bind("Email,Number,Name,Password," + "ConfirmPassword")] RegisterStaff Staff) { if (ModelState.IsValid) { var user = new ApplicationUser() { Email = Staff.Email, UserName = Staff.Name, IdNumber = Staff.Number }; var result = await _userManager.CreateAsync(user, Staff.Password); if (result.Succeeded) { var registeredUser = await _userManager.FindByEmailAsync(Staff.Email); await _userManager.AddToRoleAsync(user, "SalesStaff"); _context.Basket.Add(new Basket() { ShippingMethod = "Collection Booth", UserId = user.Id, TotalPrice = 0 }); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } TempData["UserNotifier"] = new UserNotifier() { CssFormat = "alert-danger", MessageType = "Error!", Content = "User wa not created." }; return(View(Staff)); }
protected void GrdRegistration_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label lblId = (Label)GrdRegistration.FooterRow.FindControl("lblId"); RegisterStaff registerStaff = RegisterStaffDB.GetByID(Convert.ToInt32(lblId.Text)); if (BookingDB.GetCountByProviderAndOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID) > 0) { SetErrorMessage("Can not remove registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because there exists a booking for this provider there."); return; } try { RegisterStaffDB.UpdateInactive(Convert.ToInt32(lblId.Text), false); } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { HideTableAndSetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { HideTableAndSetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); }
private void btnUpdate_Click(object sender, EventArgs e) { RegisterStaff registerStaff = new RegisterStaff(); this.Hide(); registerStaff.ShowDialog(); this.Close(); }
protected static void AddToStaffIDDayIDHash(ref Hashtable hash, ref RegisterStaff rr, DayOfWeek dayOfWeek) { if (hash[new Hashtable2D.Key(rr.Staff.StaffID, (int)dayOfWeek)] == null) { hash[new Hashtable2D.Key(rr.Staff.StaffID, (int)dayOfWeek)] = new ArrayList(); } ((ArrayList)hash[new Hashtable2D.Key(rr.Staff.StaffID, (int)dayOfWeek)]).Add(rr); }
private void hyperlinkLabelControl1_Click(object sender, EventArgs e) { flag = true; RegisterStaff registerStaff = new RegisterStaff(); this.Hide(); registerStaff.ShowDialog(); this.Close(); }
public static void UpdateActive(int register_staff_id, bool checkFKConstraint = true) { if (checkFKConstraint) { RegisterStaff registerStaff = RegisterStaffDB.GetByID(register_staff_id); if (IsStaffWorkingInOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID, false)) { throw new CustomMessageException("Can not undelete registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because a new active regsitration exists already."); } } string sql = "UPDATE RegisterStaff SET is_deleted = 0 WHERE register_staff_id = " + register_staff_id.ToString(); DBBase.ExecuteNonResult(sql); }
public static void UpdateInactive(int register_staff_id, bool checkFKConstraint = true) { if (checkFKConstraint) { RegisterStaff registerStaff = RegisterStaffDB.GetByID(register_staff_id); if (BookingDB.GetCountByProviderAndOrg(registerStaff.Staff.StaffID, registerStaff.Organisation.OrganisationID, "0") > 0) { throw new CustomMessageException("Can not remove registration of '" + registerStaff.Staff.Person.FullnameWithoutMiddlename + "' to '" + registerStaff.Organisation.Name + "' because there exists incomplete bookings for this provider there."); } } string sql = "UPDATE RegisterStaff SET is_deleted = 1 WHERE register_staff_id = " + register_staff_id.ToString(); DBBase.ExecuteNonResult(sql); }
protected string GetStaffProviderNumber(Hashtable bulkRegisterStaffHash, Hashtable bulkStaffHash, Hashtable bulkSites, Invoice invoice) { bool isClinicSite = ((Site)bulkSites[invoice.Site.SiteID]).SiteType.ID == 1; if (!isClinicSite) // aged care use prov number from staff table { // return invoice.Booking.Provider.ProviderNumber; // doesnt have all provider info loaded from the db return((bulkStaffHash != null) ? ((Staff)bulkStaffHash[invoice.Booking.Provider.StaffID]).ProviderNumber : StaffDB.GetByID(invoice.Booking.Provider.StaffID).ProviderNumber); } else // clinic use prov number specific to that clinic { if (bulkRegisterStaffHash != null) // use cached bulk preload to avoid excess db calls { if (bulkRegisterStaffHash[new Hashtable2D.Key(invoice.Booking.Provider.StaffID, invoice.Booking.Organisation.OrganisationID)] == null) { // normally doesn't pull back this info, so retrieve it for error info //invoice.Booking.Provider = StaffDB.GetByID(invoice.Booking.Provider.StaffID); //invoice.Booking.Organisation = OrganisationDB.GetByID(invoice.Booking.Organisation.OrganisationID); //string msg = @"For invoice " + invoice.InvoiceID + @" - can not get provider number for <br /> " + invoice.Booking.Provider.Person.FullnameWithoutMiddlename + @" (StaffID: " + invoice.Booking.Provider.StaffID + @")<br />at<br /> " + invoice.Booking.Organisation.Name + @" (OrgID: " + invoice.Booking.Organisation.OrganisationID + @")<br />becuase they are not registered to this clinic, and the provider number for clinic invoices is stored there."; //throw new CustomMessageException(msg); // Marcus wants it generated with empty provider number, and when rejected, they will fix it return(string.Empty); } RegisterStaff regStaff = (RegisterStaff)bulkRegisterStaffHash[new Hashtable2D.Key(invoice.Booking.Provider.StaffID, invoice.Booking.Organisation.OrganisationID)]; return(regStaff.ProviderNumber); } else { RegisterStaff regStaff = RegisterStaffDB.GetByStaffIDAndOrganisationID(invoice.Booking.Provider.StaffID, invoice.Booking.Organisation.OrganisationID); if (regStaff == null) { //string msg = @"For invoice " + invoice.InvoiceID + @" - can not get provider number for <br /> " + invoice.Booking.Provider.Person.FullnameWithoutMiddlename + @" (StaffID: " + invoice.Booking.Provider.StaffID + @")<br />at<br /> " + invoice.Booking.Organisation.Name + @" (OrgID: " + invoice.Booking.Organisation.OrganisationID + @")<br />becuase they are not registered to this clinic, and the provider number for clinic invoices is stored there."; //throw new CustomMessageException(msg); // Marcus wants it generated with empty provider number, and when rejected, they will fix it return(string.Empty); } return(regStaff.ProviderNumber); } } }
// returns 2d hashtable // get by: hash[new Hashtable2D.Key(staffID, (int)DayOfWeek.Sunday)] public static Hashtable Get2DHashByStaffIDDayID(int[] staff_ids = null) { string sql = JoinedSql + (staff_ids != null && staff_ids.Length > 0 ? @" AND r.staff_id IN(" + string.Join(",", staff_ids) + ")" : ""); DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0]; Hashtable hash = new Hashtable(); for (int i = 0; i < tbl.Rows.Count; i++) { RegisterStaff rr = Load(tbl.Rows[i], "registration_provider_number"); rr.Staff = StaffDB.Load(tbl.Rows[i], "staff_"); rr.Staff.Person = PersonDB.Load(tbl.Rows[i], "", "person_entity_id"); rr.Organisation = OrganisationDB.Load(tbl.Rows[i], "organisation_"); if (!rr.ExclSun) { AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Sunday); } if (!rr.ExclMon) { AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Monday); } if (!rr.ExclTue) { AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Tuesday); } if (!rr.ExclWed) { AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Wednesday); } if (!rr.ExclThu) { AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Thursday); } if (!rr.ExclFri) { AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Friday); } if (!rr.ExclSat) { AddToStaffIDDayIDHash(ref hash, ref rr, DayOfWeek.Saturday); } } return(hash); }
public static RegisterStaff GetByStaffIDAndOrganisationID(int staff_id, int organisation_id, bool inc_deleted = false) { string sql = JoinedSql + " AND r.staff_id = " + staff_id + " AND r.organisation_id = " + organisation_id + (inc_deleted ? "" : " AND r.is_deleted = 0 "); DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0]; if (tbl.Rows.Count == 0) { return(null); } else { RegisterStaff rr = Load(tbl.Rows[0], "registration_provider_number"); rr.Staff = StaffDB.Load(tbl.Rows[0], "staff_"); rr.Staff.Person = PersonDB.Load(tbl.Rows[0], "", "person_entity_id"); rr.Organisation = OrganisationDB.Load(tbl.Rows[0], "organisation_"); return(rr); } }
public static RegisterStaff[] GetAll() { DataTable tbl = GetDataTable_All(); RegisterStaff[] list = new RegisterStaff[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) { list[i] = RegisterStaffDB.Load(tbl.Rows[i]); list[i].Staff = StaffDB.Load(tbl.Rows[i], "staff_"); list[i].Staff.Person = PersonDB.Load(tbl.Rows[i], "", "person_entity_id"); list[i].Staff.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "title_id", "descr"); list[i].Organisation = OrganisationDB.Load(tbl.Rows[i], "organisation_"); } return(list); }
// returns 2d hashtable // get by: hash[new Hashtable2D.Key(staffID, orgID)] public static Hashtable Get2DHashByStaffIDOrgID(int[] staff_ids = null) { string sql = JoinedSql + (staff_ids != null && staff_ids.Length > 0 ? @" AND r.staff_id IN(" + string.Join(",", staff_ids) + ")" : ""); DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0]; Hashtable hash = new Hashtable(); for (int i = 0; i < tbl.Rows.Count; i++) { RegisterStaff rr = Load(tbl.Rows[i], "registration_provider_number"); rr.Staff = StaffDB.Load(tbl.Rows[i], "staff_"); rr.Staff.Person = PersonDB.Load(tbl.Rows[i], "", "person_entity_id"); rr.Organisation = OrganisationDB.Load(tbl.Rows[i], "organisation_"); hash[new Hashtable2D.Key(rr.Staff.StaffID, rr.Organisation.OrganisationID)] = rr; } return(hash); }
public static RegisterStaff GetByID(int register_staff_id) { string sql = JoinedSql + " AND register_staff_id = " + register_staff_id.ToString(); DataTable tbl = DBBase.ExecuteQuery(sql).Tables[0]; if (tbl.Rows.Count == 0) { return(null); } else { RegisterStaff rr = Load(tbl.Rows[0], "registration_provider_number"); rr.Staff = StaffDB.Load(tbl.Rows[0], "staff_"); rr.Staff.Person = PersonDB.Load(tbl.Rows[0], "", "person_entity_id"); rr.Organisation = OrganisationDB.Load(tbl.Rows[0], "organisation_"); return(rr); } }
protected void SetInvoiceInfo(Invoice invoice) { bool isDebug = Request["debug"] != null && Request["debug"] == "1"; bool useOnlyTestItems = false; SaveType saveType = Request.QueryString["reftag"] != null ? SaveType.Cancellation : SaveType.Claim; string receiptString = string.Empty; foreach (Receipt receipt in ReceiptDB.GetByInvoice(invoice.InvoiceID, false)) { receiptString += (receiptString.Length == 0 ? "" : ", ") + "$" + receipt.Total.ToString(); } string invoiceViewURL = "/Invoice_ViewV2.aspx?invoice_id=" + invoice.InvoiceID; lblInvoiceID.Text = "<a href=\"" + invoiceViewURL + "\" onclick=\"open_new_tab('" + invoiceViewURL + "');return false;\">" + invoice.InvoiceID + "</a>"; lblInvoiceTotal.Text = "$" + invoice.Total.ToString(); lblInvoiceOwing.Text = "$" + invoice.TotalDue.ToString(); lblReceiptedTotal.Text = "$" + invoice.ReceiptsTotal.ToString() + (invoice.CreditNotesTotal == 0 ? "" : " ($" + invoice.CreditNotesTotal.ToString() + " Credit Noted)") + (invoice.RefundsTotal == 0 ? "" : " ($" + invoice.RefundsTotal.ToString() + " Refunds)"); lblDebtor.Text = invoice.GetDebtor(true); lblBkDate.Text = invoice.Booking.DateStart.ToString("d MMM, yyyy"); lblBkOrgText.Text = invoice.Booking.Organisation.IsAgedCare? "Facility" : "Clinic"; lblBkOrg.Text = invoice.Booking.Organisation.Name; System.Data.DataTable tbl = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "field_id=" + invoice.Booking.Provider.Field.ID, "", "field_id", "descr"); invoice.Booking.Provider.Field = IDandDescrDB.Load(tbl.Rows[0], "field_id", "descr"); RegisterStaff regStaff = RegisterStaffDB.GetByStaffIDAndOrganisationID(invoice.Booking.Provider.StaffID, invoice.Booking.Organisation.OrganisationID); if (regStaff == null) { throw new CustomMessageException("Staff Member Not Set To This Clinic/Fac."); } InvoiceLine[] invLines = InvoiceLineDB.GetByInvoiceID(invoice.InvoiceID); Hashtable patientHealthCardCache = PatientsHealthCardsCacheDB.GetBullkActive(invLines.Select(x => x.Patient.PatientID).ToArray()); List <TyroHealthPointClaimIten> claimItems = new List <TyroHealthPointClaimIten>(); for (int i = 0; i < invLines.Length; i++) { HealthCard hc = GetHealthCardFromCache(patientHealthCardCache, invLines[i].Patient.PatientID); string ptURL = "PatientDetailV2.aspx?type=view&id=" + invLines[i].Patient.PatientID; string ptLink = "<a href=\"" + ptURL + "\" onclick=\"open_new_tab('" + ptURL + "');return false;\">" + invLines[i].Patient.Person.FullnameWithoutMiddlename + "</a>"; if (hc == null) { throw new CustomMessageException("No healthcard found for " + ptLink + " (PT-ID:" + invLines[i].Patient.PatientID + ")"); } if (hc.Organisation.OrganisationType.OrganisationTypeID != 150) { throw new CustomMessageException("Healthcard found for " + ptLink + " (PT-ID:" + invLines[i].Patient.PatientID + ") Is Not An Insurance Card"); } /* * claim-amount: claim amount in cents - max 10 digits * service-code: item number service code - max 5 characters * description: description of item to appear on receipt - max 32 characters * service-reference: body part or tooth number suffix - max 3 characters * patient-id: patient ID on card - exactly 2 digits * service-date: claim date in YYYYMMDD format */ isDebug = true; claimItems.Add(new TyroHealthPointClaimIten( ((int)(invLines[i].Price * 100)).ToString(), isDebug ? "F1234" : invLines[i].Offering.TacCompanyCode, isDebug ? "Face" : invLines[i].AreaTreated, invLines[i].ServiceReference, "", // family number on card -- legally they have to enter it themselves isDebug ? DateTime.Today.ToString("yyyyMMdd") : invoice.Booking.DateStart.ToString("yyyyMMdd"))); } //useOnlyTestItems = true; // save variables & JSON array on the page accessable to JS to send to Tyro if (useOnlyTestItems) { claimItems = new List <TyroHealthPointClaimIten>(); claimItems.Add(new TyroHealthPointClaimIten( "10000", "00001", "SKULL XRAY", "01", "02", DateTime.Today.ToString("yyyyMMdd"))); claimItems.Add(new TyroHealthPointClaimIten( "15000", "00001", "SKULL XRAY", "01", "02", DateTime.Today.ToString("yyyyMMdd"))); Page.ClientScript.RegisterStartupScript(this.GetType(), "invoice_items", @"<script language=javascript> var _providerId = '4237955J'; var _serviceType = 'D'; var _claimItemsCount = '2'; var _totalClaimAmount = '25000'; var _allClaimItems = " + new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(claimItems) + @"; </script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "invoice_items", @"<script language=javascript> var _providerId = '" + (isDebug ? "4237955J" : (regStaff.ProviderNumber.Length > 0 ? regStaff.ProviderNumber : invoice.Booking.Provider.ProviderNumber)) + @"'; var _serviceType = '" + GetServiceTypeHashtable()[invoice.Booking.Provider.Field.Descr.ToLower()].ToString() + @"'; var _claimItemsCount = '" + invLines.Length.ToString() + @"'; var _totalClaimAmount = '" + ((int)(invLines.Sum(item => item.Price) * 100)).ToString() + @"'; var _allClaimItems = " + new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(claimItems) /* convert to JSON array */ + @"; " + (saveType == SaveType.Cancellation ? "var _refTag = " + Request.QueryString["reftag"] : string.Empty) + @" </script>"); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { Utilities.SetNoCache(Response); } HideErrorMessage(); if (!IsPostBack) { PagePermissions.EnforcePermissions_RequireAny(Session, Response, true, true, true, true, true, false); Session.Remove("invoicelistac_sortexpression"); Session.Remove("invoicelistac_data"); if (!IsValidFormBooking()) { throw new CustomMessageException("No booking in url"); } Booking booking = BookingDB.GetByID(GetFormBooking()); string orgAddressText; if (Utilities.GetAddressType().ToString() == "Contact") { Contact orgAddress = ContactDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1); orgAddressText = orgAddress == null ? "No address found" : orgAddress.GetFormattedAddress("No address found"); } else if (Utilities.GetAddressType().ToString() == "ContactAus") { ContactAus orgAddressAus = ContactAusDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1); orgAddressText = orgAddressAus == null ? "No address found" : orgAddressAus.GetFormattedAddress("No address found"); } else { throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString()); } lblTreatmentDate.Text = booking.DateStart.ToString("d MMM, yyyy") + " " + booking.DateStart.ToString("H:mm") + (booking.DateStart.Hour < 12 ? "am" : "pm"); lblOrgType.Text = booking.Organisation.OrganisationType.Descr; lblOrgName.Text = booking.Organisation.Name; lblOrgAddress.Text = orgAddressText.Replace(Environment.NewLine, "<br />"); lblProviderName.Text = booking.Provider.Person.FullnameWithoutMiddlename; lblProviderNbr.Text = booking.Provider.ProviderNumber; string link = @"http://localhost:2524/Invoice_ViewV2.aspx?booking_id=264225"; lblInvLink.Text = "<a href=\"" + link + "\" onclick=\"open_new_tab('" + link + "');return false;\">View All Invoices</a>"; if (!booking.Organisation.IsAgedCare) { tr_address.Visible = false; btnEmailToFac.Visible = false; br_before_email_to_fac.Visible = false; RegisterStaff regStaff = RegisterStaffDB.GetByStaffIDAndOrganisationID(booking.Provider.StaffID, booking.Organisation.OrganisationID, true); if (regStaff != null) { lblProviderNbr.Text = regStaff.ProviderNumber; } } FillGrid(); } this.GrdBooking.EnableViewState = true; } catch (CustomMessageException ex) { if (IsPostBack) { SetErrorMessage(ex.Message); } else { HideTableAndSetErrorMessage(ex.Message); } } catch (Exception ex) { if (IsPostBack) { SetErrorMessage("", ex.ToString()); } else { HideTableAndSetErrorMessage("", ex.ToString()); } } }
public static RegisterStaff[] GetAll() { DataTable tbl = GetDataTable_All(); RegisterStaff[] list = new RegisterStaff[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) { list[i] = RegisterStaffDB.Load(tbl.Rows[i]); list[i].Staff = StaffDB.Load(tbl.Rows[i], "staff_"); list[i].Staff.Person = PersonDB.Load(tbl.Rows[i], "", "person_entity_id"); list[i].Staff.Person.Title = IDandDescrDB.Load(tbl.Rows[i], "title_id", "descr"); list[i].Organisation = OrganisationDB.Load(tbl.Rows[i], "organisation_"); } return list; }
protected static void AddToStaffIDDayIDHash(ref Hashtable hash, ref RegisterStaff rr, DayOfWeek dayOfWeek) { if (hash[new Hashtable2D.Key(rr.Staff.StaffID, (int)dayOfWeek)] == null) hash[new Hashtable2D.Key(rr.Staff.StaffID, (int)dayOfWeek)] = new ArrayList(); ((ArrayList)hash[new Hashtable2D.Key(rr.Staff.StaffID, (int)dayOfWeek)]).Add(rr); }
protected bool IsWorkingToday(DayOfWeek dayOfWeek, RegisterStaff registerStaff) { return ((dayOfWeek == DayOfWeek.Sunday && registerStaff != null && !registerStaff.ExclSun) || (dayOfWeek == DayOfWeek.Monday && registerStaff != null && !registerStaff.ExclMon) || (dayOfWeek == DayOfWeek.Tuesday && registerStaff != null && !registerStaff.ExclTue) || (dayOfWeek == DayOfWeek.Wednesday && registerStaff != null && !registerStaff.ExclWed) || (dayOfWeek == DayOfWeek.Thursday && registerStaff != null && !registerStaff.ExclThu) || (dayOfWeek == DayOfWeek.Friday && registerStaff != null && !registerStaff.ExclFri) || (dayOfWeek == DayOfWeek.Saturday && registerStaff != null && !registerStaff.ExclSat)); }
protected string[] GetProviderData(Site site, Offering selectedOffering, DateTime fromDate, DateTime endDate, Staff staff, Organisation org, RegisterStaff registerStaff, Booking[] bookings = null, bool incClinic = false) { int d = 0; string[] data = new string[(int)endDate.Subtract(fromDate).TotalDays + 2 + (incClinic ? 1 : 0)]; if (incClinic) { data[d] = org.Name; d++; } data[d] = staff.Person.FullnameWithoutMiddlename; d++; data[d] = staff.Field.Descr; d++; Organisation[] orgs = new Organisation[] { org }; Staff[] providers = new Staff[] { staff }; if (bookings == null) bookings = BookingDB.GetBetween(fromDate, endDate, providers, orgs, null, null); // seperate into // - individual bookings that can be retrieved by date // - recurring bookings that can be retrieved by day of week Hashtable bkRecurringHash = new Hashtable(); Hashtable bkDateHash = new Hashtable(); foreach (Booking curBooking in bookings) { if (curBooking.Provider != null && curBooking.Provider.StaffID != staff.StaffID) continue; //if (curBooking.Organisation != null && curBooking.Organisation.OrganisationID != orgs[0].OrganisationID) // continue; if (!curBooking.IsRecurring) { if (bkDateHash[curBooking.DateStart.Date] == null) bkDateHash[curBooking.DateStart.Date] = new ArrayList(); if (IsWorkingToday(curBooking.DateStart.DayOfWeek, registerStaff)) ((ArrayList)bkDateHash[curBooking.DateStart.Date]).Add(curBooking); } else // curBooking.IsRecurring { if (bkRecurringHash[curBooking.RecurringDayOfWeek] == null) bkRecurringHash[curBooking.RecurringDayOfWeek] = new ArrayList(); if (IsWorkingToday(curBooking.RecurringDayOfWeek, registerStaff)) ((ArrayList)bkRecurringHash[curBooking.RecurringDayOfWeek]).Add(curBooking); } } for (DateTime curDate = fromDate; curDate < endDate; curDate = curDate.AddDays(1), d++) { Tuple<DateTime, DateTime> startEndTime = GetStartEndTime(curDate, orgs[0], site); Tuple<DateTime, DateTime> orgLunchTime = GetOrgLunchStartTime(curDate, orgs[0]); Booking[] todayBookings = bkDateHash[curDate] == null ? new Booking[] { } : (Booking[])((ArrayList)bkDateHash[curDate]).ToArray(typeof(Booking)); Booking[] todayRecurring = bkRecurringHash[curDate.DayOfWeek] == null ? new Booking[] { } : (Booking[])((ArrayList)bkRecurringHash[curDate.DayOfWeek]).ToArray(typeof(Booking)); if (IsWorkingToday(curDate.DayOfWeek, registerStaff) && IsClinicOpenToday(curDate, orgs[0])) { //foreach (Booking curBooking in todayBookings) // output1 += "<tr><td></td><td>" + curBooking.BookingID + "</td><td>" + curBooking.BookingTypeID + "</td><td style=\"white-space:nowrap;\">" + (curBooking.Organisation == null ? "" : curBooking.Organisation.Name) + "</td><td style=\"white-space:nowrap;\">" + (curBooking.Provider == null ? "" : curBooking.Provider.Person.FullnameWithoutMiddlename) + "</td><td style=\"white-space:nowrap;\">" + curBooking.DateStart.ToString("dd MMM yyyy") + "</td><td style=\"white-space:nowrap;\">" + "[" + curBooking.DateStart.ToString("HH:mm") + " - " + curBooking.DateEnd.ToString("HH:mm") + "]" + "</td></tr>"; // //foreach (Booking curBooking in todayRecurring) // if (curDate >= curBooking.DateStart.Date && curDate <= curBooking.DateEnd.Date) // output1 += "<tr><td> <b>R</b> </td><td>" + curBooking.BookingID + "</td><td>" + curBooking.BookingTypeID + "</td><td style=\"white-space:nowrap;\">" + (curBooking.Organisation == null ? "" : curBooking.Organisation.Name) + "</td><td style=\"white-space:nowrap;\">" + (curBooking.Provider == null ? "" : curBooking.Provider.Person.FullnameWithoutMiddlename) + "</td><td style=\"white-space:nowrap;\">" + curBooking.DateStart.ToString("dd MMM yyyy") + "</td><td style=\"white-space:nowrap;\">" + "[" + new DateTime(curBooking.RecurringStartTime.Ticks).ToString("HH:mm") + " - " + new DateTime(curBooking.RecurringEndTime.Ticks).ToString("HH:mm") + "]" + "</td></tr>"; // list of all TAKEN times List<Tuple<DateTime, DateTime>> dateRows = new List<Tuple<DateTime, DateTime>>(); // add lunch breaks if (site.LunchStartTime < site.LunchEndTime) AddToDateRows(ref dateRows, startEndTime, curDate.Add(site.LunchStartTime), curDate.Add(site.LunchEndTime)); if (orgLunchTime.Item1 < orgLunchTime.Item2) AddToDateRows(ref dateRows, startEndTime, orgLunchTime.Item1, orgLunchTime.Item2); // add individual bookings/unavailabilities foreach (Booking curBooking in todayBookings) AddToDateRows(ref dateRows, startEndTime, curBooking.DateStart, curBooking.DateEnd); // add recurring bookings/unavailabilities foreach (Booking curBooking in todayRecurring) { if ((curBooking.DateStart != DateTime.MinValue && curDate < curBooking.DateStart.Date) || (curBooking.DateEnd != DateTime.MinValue && curDate > curBooking.DateEnd.Date)) continue; DateTime bkStart = curDate.Add(curBooking.RecurringStartTime); DateTime bkEnd = curDate.Add(curBooking.RecurringEndTime); AddToDateRows(ref dateRows, startEndTime, bkStart, bkEnd); } dateRows = SortAndRemoveOverlaps(dateRows); // list of all AVAILABLE times List<Tuple<DateTime, DateTime>> availableTimeRows = GetAvailableTimes(startEndTime, dateRows); //output1 += "<tr><td colspan=\"7\"><u>Available Times:</u><br />" + PrintList(availableTimeRows) + "</td></tr>"; // remove times when the space available is less than the default minutes set for the offering selected for (int i = availableTimeRows.Count - 1; i >= 0; i--) if (availableTimeRows[i].Item2.Subtract(availableTimeRows[i].Item1).TotalMinutes < selectedOffering.ServiceTimeMinutes) availableTimeRows.RemoveAt(i); //output1 += "<tr><td colspan=\"7\"><u>Available Times:</u><br />" + PrintList(availableTimeRows) + "</td></tr>"; if (availableTimeRows.Count > 0) { string bookingSheetLink = IsLoggedIn() ? "<a href= \"" + Booking.GetLink(curDate, new int[] { orgs[0].OrganisationID }) + "\"><img src=\"/images/Calendar-icon-24px.png\" alt=\"Go To Booking Sheet\" title=\"Go To Booking Sheet\"></a>" : "<a href= \"/Account/CreateNewPatientV2.aspx?id=" + Request.QueryString["id"] + "&from_url=" + Server.UrlEncode(Booking.GetLink(curDate, new int[] { orgs[0].OrganisationID })) + "\"><img src=\"/images/Calendar-icon-24px.png\" alt=\"Go To Booking Sheet\" title=\"Go To Booking Sheet\"></a>"; data[d] = "<td style=\"background:#ffffff !important; border-left:none !important;border-right:none !important;min-width:45px;\"></td><td style=\"background:#ffffff !important; white-space:nowrap;border-left:none !important;border-right:none !important;\"><u>Available Times</u><br />" + PrintList(availableTimeRows, org.OrganisationID, staff.StaffID) + "</td><td style=\"background:#ffffff !important; border-left:none !important;border-right:none !important;min-width:18px;\"></td><td style=\"background:#ffffff !important; border-left:none !important;\">" + bookingSheetLink + "</td>"; } else data[d] = "<td style=\"border-left:none !important;\" colspan=\"4\">Unavailable</td>"; } else { data[d] = "<td style=\"border-left:none !important;\" colspan=\"4\">Unavailable</td>"; } } return data; }
protected void MergeFile(bool isAgedCare, string originalFile, string outputFile) { Booking booking = BookingDB.GetByID(GetFormBooking()); DataTable dt = Session["invoicelistac_data"] as DataTable; string orgAddressText, orgAddressTabbedText, orgPhoneText, orgFaxText, orgWebText, orgEmailText; if (Utilities.GetAddressType().ToString() == "Contact") { Contact orgAddress = ContactDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1); Contact orgPhone = ContactDB.GetFirstByEntityID(null, booking.Organisation != null ? booking.Organisation.EntityID : -1, "30,33,34"); Contact orgFax = ContactDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 29); Contact orgWeb = ContactDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 28); Contact orgEmail = ContactDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 27); orgAddressText = orgAddress == null ? "No address found" : orgAddress.GetFormattedAddress("No address found"); orgAddressTabbedText = orgAddress == null ? "No address found" : orgAddress.GetFormattedAddress("No address found", 1); orgPhoneText = orgPhone == null ? "No phone number found" : orgPhone.GetFormattedPhoneNumber("No phone number found"); orgFaxText = orgFax == null ? "No fax number found" : orgFax.GetFormattedPhoneNumber("No fax number found"); orgWebText = orgWeb == null ? "No website found" : orgWeb.AddrLine1; orgEmailText = orgEmail == null ? "No email found" : orgEmail.AddrLine1; } else if (Utilities.GetAddressType().ToString() == "ContactAus") { ContactAus orgAddressAus = ContactAusDB.GetFirstByEntityID(1, booking.Organisation != null ? booking.Organisation.EntityID : -1); ContactAus orgPhoneAus = ContactAusDB.GetFirstByEntityID(null, booking.Organisation != null ? booking.Organisation.EntityID : -1, "30,33,34"); ContactAus orgFaxAus = ContactAusDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 29); ContactAus orgWebAus = ContactAusDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 28); ContactAus orgEmailAus = ContactAusDB.GetFirstByEntityID(-1, booking.Organisation != null ? booking.Organisation.EntityID : -1, 27); orgAddressText = orgAddressAus == null ? "No address found" : orgAddressAus.GetFormattedAddress("No address found"); orgAddressTabbedText = orgAddressAus == null ? "No address found" : orgAddressAus.GetFormattedAddress("No address found", 1); orgPhoneText = orgPhoneAus == null ? "No phone number found" : orgPhoneAus.GetFormattedPhoneNumber("No phone number found"); orgFaxText = orgFaxAus == null ? "No fax number found" : orgFaxAus.GetFormattedPhoneNumber("No fax number found"); orgWebText = orgWebAus == null ? "No website found" : orgWebAus.AddrLine1; orgEmailText = orgEmailAus == null ? "No email found" : orgEmailAus.AddrLine1; } else { throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString()); } string providerNumber = booking.Provider.ProviderNumber; if (!isAgedCare) { RegisterStaff regStaff = RegisterStaffDB.GetByStaffIDAndOrganisationID(booking.Provider.StaffID, booking.Organisation.OrganisationID, true); if (regStaff != null) { providerNumber = regStaff.ProviderNumber; } } System.Data.DataSet sourceDataSet = new System.Data.DataSet(); sourceDataSet.Tables.Add("MergeIt"); sourceDataSet.Tables[0].Columns.Add("curr_date"); sourceDataSet.Tables[0].Columns.Add("bk_prov_fullname"); sourceDataSet.Tables[0].Columns.Add("bk_prov_number"); sourceDataSet.Tables[0].Columns.Add("bk_date"); sourceDataSet.Tables[0].Columns.Add("bk_org_name"); sourceDataSet.Tables[0].Columns.Add("bk_org_abn"); sourceDataSet.Tables[0].Columns.Add("bk_org_acn"); sourceDataSet.Tables[0].Columns.Add("bk_org_bpay_account"); sourceDataSet.Tables[0].Columns.Add("bk_org_addr"); sourceDataSet.Tables[0].Columns.Add("bk_org_addr_tabbedx1"); sourceDataSet.Tables[0].Columns.Add("bk_org_phone"); sourceDataSet.Tables[0].Columns.Add("bk_org_office_fax"); sourceDataSet.Tables[0].Columns.Add("bk_org_web"); sourceDataSet.Tables[0].Columns.Add("bk_org_email"); sourceDataSet.Tables[0].Rows.Add( DateTime.Now.ToString("d MMMM, yyyy"), booking.Provider.Person.FullnameWithoutMiddlename, providerNumber, booking.DateStart.ToString("d MMMM, yyyy"), booking.Organisation.Name, booking.Organisation.Abn, booking.Organisation.Acn, booking.Organisation.BpayAccount, orgAddressText, orgAddressTabbedText, orgPhoneText, orgFaxText, orgWebText, orgEmailText ); string[,] tblInfo = new string[dt.Rows.Count, isAgedCare ? 5 : 4]; for (int i = 0; i < dt.Rows.Count; i++) { if (isAgedCare) { /* * 0 = i (row nbr) * 1 = room (addr1 of patient) * 2 = resident * 3 = resident type * 4 = debtor */ tblInfo[i, 0] = (i + 1).ToString(); tblInfo[i, 1] = dt.Rows[i]["Room"].ToString(); tblInfo[i, 2] = dt.Rows[i]["PatientName"].ToString(); tblInfo[i, 3] = dt.Rows[i]["ItemDescr"].ToString(); tblInfo[i, 4] = dt.Rows[i]["Debtor"].ToString(); } else { /* * 0 = i (row nbr) * 1 = patient * 2 = service * 3 = debtor */ tblInfo[i, 0] = (i + 1).ToString(); tblInfo[i, 1] = dt.Rows[i]["PatientName"].ToString(); tblInfo[i, 2] = dt.Rows[i]["ItemDescr"].ToString(); tblInfo[i, 3] = dt.Rows[i]["Debtor"].ToString(); } } // merge string errorString = null; WordMailMerger.Merge( originalFile, outputFile, sourceDataSet, tblInfo, 1, true, true, null, true, null, out errorString); if (errorString != string.Empty) { throw new Exception(errorString); } }