Beispiel #1
0
 public static void Delete(int person_id)
 {
     try
     {
         Person p = PersonDB.GetByID(person_id);
         if (p != null)
         {
             DBBase.ExecuteNonResult("DELETE FROM Person WHERE person_id = " + person_id.ToString() + "; DBCC CHECKIDENT(Person,RESEED,1); DBCC CHECKIDENT(Person);");
             if (EntityDB.NumForeignKeyDependencies(p.EntityID) == 0)
             {
                 EntityDB.Delete(p.EntityID, false);
             }
         }
     }
     catch (System.Data.SqlClient.SqlException sqlEx)
     {
         if (sqlEx.Errors.Count > 0 && sqlEx.Errors[0].Number == 547) // Assume the interesting stuff is in the first error
         {
             throw new ForeignKeyConstraintException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, sqlEx);
         }
         else
         {
             throw;
         }
     }
 }
    private void FillEditViewForm(Staff staff, bool isEditMode)
    {
        Page.Title = ((SystemVariables)Session["SystemVariables"])["Site"].Value + " - " + staff.Person.FullnameWithoutMiddlename;

        staff.Person = PersonDB.GetByID(staff.Person.PersonID);
        Person addedBy = staff.Person.PersonID < 0 ? null : PersonDB.GetByID(staff.Person.AddedBy);

        if (!Utilities.IsDev())
        {
            idRow.Attributes["class"] = "hiddencol";
        }



        this.lnkThisStaff.Visible     = true;
        this.lnkThisStaff.NavigateUrl = "~/RegisterOrganisationsToStaffV2.aspx?id=" + Request.QueryString["id"].ToString();
        this.lnkThisStaff.Text        = "Edit";


        lblId.Text             = staff.StaffID.ToString();
        lblAddedBy.Text        = addedBy == null ? "" : addedBy.Firstname + " " + addedBy.Surname;
        lblStaffDateAdded.Text = staff.StaffDateAdded.ToString("dd-MM-yyyy");

        txtComments.Text = staff.Comment;


        if (isEditMode)
        {
            DataTable titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", staff.Person.Title.ID == 0 ? "" : " title_id <> 0 ", " descr ", "title_id", "descr");
            ddlTitle.DataSource = titles;
            ddlTitle.DataBind();

            if (staff.StartDate != DateTime.MinValue)
            {
                ddlStartDate_Day.SelectedValue   = staff.StartDate.Day.ToString();
                ddlStartDate_Month.SelectedValue = staff.StartDate.Month.ToString();
                ddlStartDate_Year.SelectedValue  = staff.StartDate.Year.ToString();
            }
            if (staff.EndDate != DateTime.MinValue)
            {
                ddlEndDate_Day.SelectedValue   = staff.EndDate.Day.ToString();
                ddlEndDate_Month.SelectedValue = staff.EndDate.Month.ToString();
                ddlEndDate_Year.SelectedValue  = staff.EndDate.Year.ToString();
            }
            ddlTitle.SelectedValue = staff.Person.Title.ID.ToString();
            txtFirstname.Text      = staff.Person.Firstname;
            txtMiddlename.Text     = staff.Person.Middlename;
            txtSurname.Text        = staff.Person.Surname;
            if (ddlGender.Items.FindByValue(staff.Person.Gender) == null)
            {
                ddlGender.Items.Add(new ListItem(staff.Person.Gender == "" ? "" : staff.Person.Gender, staff.Person.Gender));
            }
            ddlGender.SelectedValue = staff.Person.Gender;

            txtLogin.Text = staff.Login;
            txtPwd.Text   = staff.Pwd;
            txtPwd.Attributes["value"] = staff.Pwd;
            ddlStatus.SelectedValue    = staff.IsFired ? "Inactive" : "Active";

            lblTitle.Visible      = false;
            lblFirstname.Visible  = false;
            lblMiddlename.Visible = false;
            lblSurname.Visible    = false;
            lblGender.Visible     = false;
            lblLogin.Visible      = false;
            lblPwd.Visible        = false;
            lblIsFired.Visible    = false;
        }
        else
        {
            lblTitle.Text      = staff.Person.Title.ID == 0 ? "" : staff.Person.Title.Descr;
            lblFirstname.Text  = staff.Person.Firstname.Length == 0 ? "" : staff.Person.Firstname;
            lblMiddlename.Text = staff.Person.Middlename.Length == 0 ? "" : staff.Person.Middlename;
            lblSurname.Text    = staff.Person.Surname.Length == 0 ? "" : staff.Person.Surname;
            lblGender.Text     = GetGenderText(staff.Person.Gender);
            lblLogin.Text      = staff.Login.Length == 0 ? "" : staff.Login;
            lblIsFired.Text    = staff.IsFired                       ? "<b><font color=\"red\">Inactive</font></b>" : "Active";

            lblStartDate.Text = staff.StartDate == DateTime.MinValue ? "" : staff.StartDate.ToString("dd-MM-yyyy");
            lblEndDate.Text   = staff.EndDate == DateTime.MinValue ? "" : staff.EndDate.ToString("dd-MM-yyyy");

            lblAddedBy.Font.Bold        = true;
            lblStaffDateAdded.Font.Bold = true;

            txtComments.Enabled   = false;
            txtComments.ForeColor = System.Drawing.Color.Black;



            ddlTitle.Visible      = false;
            txtFirstname.Visible  = false;
            txtMiddlename.Visible = false;
            txtSurname.Visible    = false;
            ddlGender.Visible     = false;

            ddlStartDate_Day.Visible   = false;
            ddlStartDate_Month.Visible = false;
            ddlStartDate_Year.Visible  = false;
            ddlEndDate_Day.Visible     = false;
            ddlEndDate_Month.Visible   = false;
            ddlEndDate_Year.Visible    = false;

            txtLogin.Visible  = false;
            txtPwd.Visible    = false;
            ddlStatus.Visible = false;
        }


        DataTable incList = RegisterStaffDB.GetDataTable_OrganisationsOf(staff.StaffID);

        incList.DefaultView.Sort = "name ASC";
        if (incList.Rows.Count == 0)
        {
            lstClinics.Items.Add(new ListItem("No Clinics Allocated Yet"));
        }
        else
        {
            foreach (DataRowView row in incList.DefaultView)
            {
                lstClinics.Items.Add(new ListItem(row["name"].ToString()));
            }
        }

        UpdateSiteRestrictions();
        SetBookingsList(staff);

        btnSubmit.Text    = isEditMode ? "Update Details" : "Edit Details";
        btnCancel.Visible = isEditMode;
    }
Beispiel #3
0
    protected void FillGrid()
    {
        if (!IsValidFormID())
        {
            HideTableAndSetErrorMessage("", "Invalid URL Parameters");
            return;
        }

        Staff staff = StaffDB.GetByID(GetFormID());

        if (staff == null)
        {
            HideTableAndSetErrorMessage("", "Invalid URL Parameters");
            return;
        }
        staff.Person = PersonDB.GetByID(staff.Person.PersonID);

        lblHeading.Text = Page.Title = "Manage Clinics/Facilities For :  " + staff.Person.Firstname + " " + staff.Person.Surname;
        this.lnkThisStaff.NavigateUrl = staff.IsExternal ?  "~/StaffDetailExternalV2.aspx?type=view&id=" + GetFormID().ToString() :  "~/StaffDetailV2.aspx?type=view&id=" + GetFormID().ToString();
        this.lnkThisStaff.Text        = "Back to details for " + staff.Person.Firstname + " " + staff.Person.Surname;


        if (staff.IsExternal)
        {
            GrdRegistration.Columns[3].Visible  = false;
            GrdRegistration.Columns[4].Visible  = false;
            GrdRegistration.Columns[5].Visible  = false;
            GrdRegistration.Columns[6].Visible  = false;
            GrdRegistration.Columns[7].Visible  = false;
            GrdRegistration.Columns[8].Visible  = false;
            GrdRegistration.Columns[9].Visible  = false;
            GrdRegistration.Columns[10].Visible = false;
            GrdRegistration.Columns[11].Visible = false;
        }


        DataTable dt = RegisterStaffDB.GetDataTable_OrganisationsOf(staff.StaffID, null, chkShowDeleted.Checked);

        Session["registerorgtostaff_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["registerorgtostaff_sortexpression"] != null && Session["registerorgtostaff_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort = Session["registerorgtostaff_sortexpression"].ToString();
                GrdRegistration.DataSource = dataView;
            }
            else
            {
                GrdRegistration.DataSource = dt;
            }


            try
            {
                GrdRegistration.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdRegistration.DataSource = dt;
            GrdRegistration.DataBind();

            int TotalColumns = GrdRegistration.Rows[0].Cells.Count;
            GrdRegistration.Rows[0].Cells.Clear();
            GrdRegistration.Rows[0].Cells.Add(new TableCell());
            GrdRegistration.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdRegistration.Rows[0].Cells[0].Text       = "No Record Found";
        }

        if (hideFotter)
        {
            GrdRegistration.FooterRow.Visible = false;
        }
    }
Beispiel #4
0
    private void FillEditViewForm(Staff staff, bool isEditMode)
    {
        Page.Title = ((SystemVariables)Session["SystemVariables"])["Site"].Value + " - " + staff.Person.FullnameWithoutMiddlename;

        staff.Person = PersonDB.GetByID(staff.Person.PersonID);
        Person addedBy = staff.Person.PersonID < 0 ? null : PersonDB.GetByID(staff.Person.AddedBy);

        if (!Utilities.IsDev())
        {
            idRow.Attributes["class"] = "hiddencol";
        }

        this.lnkBookingList.Visible     = true;
        this.lnkBookingList.NavigateUrl = "~/BookingsListV2.aspx?staff=" + Request.QueryString["id"].ToString();
        this.lnkBookingList.Text        = "Bookings List";

        string allFeatures = "dialogWidth:1250px;dialogHeight:835px;center:yes;resizable:no; scroll:no";
        string js          = "javascript:window.showModalDialog('" + "BookingSheetBlockoutV2.aspx?staff=" + staff.StaffID.ToString() + "', '', '" + allFeatures + "');return false;";

        this.lnkUnavailabilities.Attributes.Add("onclick", js);
        lnkUnavailabilities.NavigateUrl = "javascript:void(0)";

        UpdateGenerateSystemLetters();

        this.lnkThisStaff.Visible     = true;
        this.lnkThisStaff.NavigateUrl = "~/RegisterOrganisationsToStaffV2.aspx?id=" + Request.QueryString["id"].ToString();
        this.lnkThisStaff.Text        = "Edit";

        this.lnkStaffOfferings.Visible     = true;
        this.lnkStaffOfferings.NavigateUrl = "~/StaffOfferingsListV2.aspx?staff=" + Request.QueryString["id"].ToString();
        this.lnkStaffOfferings.Text        = "Set Comissions/Fixed Rates";


        lblId.Text             = staff.StaffID.ToString();
        lblAddedBy.Text        = addedBy == null ? "" : addedBy.Firstname + " " + addedBy.Surname;
        lblStaffDateAdded.Text = staff.StaffDateAdded.ToString("dd-MM-yyyy");

        txtComments.Text = staff.Comment;


        if (isEditMode)
        {
            DataTable titles = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", staff.Person.Title.ID == 0 ? "" : " title_id <> 0 ", " descr ", "title_id", "descr");
            ddlTitle.DataSource = titles;
            ddlTitle.DataBind();
            DataTable fields = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Field", "field_id <> 0", "descr", "field_id", "descr");
            ddlField.DataSource = fields;
            ddlField.DataBind();
            //DataTable costcentres = CostCentreDB.GetDataTable();
            //ddlCostCentre.DataSource = costcentres;
            //ddlCostCentre.DataBind();

            if (staff.StartDate != DateTime.MinValue)
            {
                ddlStartDate_Day.SelectedValue   = staff.StartDate.Day.ToString();
                ddlStartDate_Month.SelectedValue = staff.StartDate.Month.ToString();
                ddlStartDate_Year.SelectedValue  = staff.StartDate.Year.ToString();
            }
            if (staff.EndDate != DateTime.MinValue)
            {
                ddlEndDate_Day.SelectedValue   = staff.EndDate.Day.ToString();
                ddlEndDate_Month.SelectedValue = staff.EndDate.Month.ToString();
                ddlEndDate_Year.SelectedValue  = staff.EndDate.Year.ToString();
            }
            ddlTitle.SelectedValue = staff.Person.Title.ID.ToString();
            txtFirstname.Text      = staff.Person.Firstname;
            txtMiddlename.Text     = staff.Person.Middlename;
            txtSurname.Text        = staff.Person.Surname;
            if (ddlGender.Items.FindByValue(staff.Person.Gender) == null)
            {
                ddlGender.Items.Add(new ListItem(staff.Person.Gender == "" ? "" : staff.Person.Gender, staff.Person.Gender));
            }
            ddlGender.SelectedValue = staff.Person.Gender;
            if (staff.Person.Dob != DateTime.MinValue)
            {
                ddlDOB_Day.SelectedValue   = staff.Person.Dob.Day.ToString();
                ddlDOB_Month.SelectedValue = staff.Person.Dob.Month.ToString();
                ddlDOB_Year.SelectedValue  = staff.Person.Dob.Year.ToString();
            }
            txtLogin.Text = staff.Login;
            txtPwd.Text   = staff.Pwd;
            txtPwd.Attributes["value"] = staff.Pwd;

            if (ddlField.Items.FindByValue(staff.Field.ID.ToString()) == null)
            {
                ddlField.Items.Add(new ListItem(staff.Field.Descr, staff.Field.ID.ToString()));
            }

            ddlField.SelectedValue  = staff.Field.ID.ToString();
            chkContractor.Checked   = staff.IsContractor;
            txtTFN.Text             = staff.Tfn;
            ddlStatus.SelectedValue = staff.IsFired ? "Inactive" : "Active";
            chkSMSBKs.Checked       = staff.EnableDailyReminderSMS;
            chkEmailBKs.Checked     = staff.EnableDailyReminderEmail;
            //ddlCostCentre.SelectedValue    = staff.CostCentre.CostCentreID.ToString();
            txtProviderNumber.Text    = staff.ProviderNumber;
            chkIsCommission.Checked   = staff.IsCommission;
            txtCommissionPercent.Text = staff.CommissionPercent.ToString();
            chkIsProvider.Checked     = staff.IsProvider;
            chkIsPrincipal.Checked    = staff.IsPrincipal;
            chkIsAdmin.Checked        = staff.IsAdmin;
            chkIsMasterAdmin.Checked  = staff.IsMasterAdmin;
            chkIsStakeholder.Checked  = staff.IsStakeholder;

            lblTitle.Visible      = false;
            lblFirstname.Visible  = false;
            lblMiddlename.Visible = false;
            lblSurname.Visible    = false;
            lblGender.Visible     = false;
            lblDOB.Visible        = false;
            lblLogin.Visible      = false;
            lblPwd.Visible        = false;
            lblField.Visible      = false;
            lblContractor.Visible = false;
            lblTFN.Visible        = false;
            //lblCostCentre.Visible         = false;
            lblProviderNumber.Visible    = false;
            lblIsCommission.Visible      = false;
            lblCommissionPercent.Visible = false;
            lblIsFired.Visible           = false;
            lblSMSBKs.Visible            = false;
            lblEmailBKs.Visible          = false;
            lblIsProvider.Visible        = false;
            lblIsPrincipal.Visible       = false;
            lblIsAdmin.Visible           = false;
            lblIsMasterAdmin.Visible     = false;
            lblIsStakeholder.Visible     = false;
        }
        else
        {
            lblTitle.Text      = staff.Person.Title.ID == 0 ? "" : staff.Person.Title.Descr;
            lblFirstname.Text  = staff.Person.Firstname.Length == 0 ? "" : staff.Person.Firstname;
            lblMiddlename.Text = staff.Person.Middlename.Length == 0 ? "" : staff.Person.Middlename;
            lblSurname.Text    = staff.Person.Surname.Length == 0 ? "" : staff.Person.Surname;
            lblGender.Text     = GetGenderText(staff.Person.Gender);
            lblDOB.Text        = staff.Person.Dob == DateTime.MinValue ? "" : staff.Person.Dob.ToString("dd-MM-yyyy");
            lblLogin.Text      = staff.Login.Length == 0 ? "" : staff.Login;
            lblField.Text      = staff.Field.Descr;
            lblContractor.Text = staff.IsContractor  ? "Yes" : "No";
            lblTFN.Text        = staff.Tfn.Length == 0 ? "" : staff.Tfn;
            //lblCostCentre.Text        = staff.CostCentre.Descr.Length  == 0 ? "" : staff.CostCentre.Descr;
            lblProviderNumber.Text    = staff.ProviderNumber.Length == 0 ? "" : staff.ProviderNumber;
            lblIsCommission.Text      = staff.IsCommission  ? "Yes" : "No";
            lblCommissionPercent.Text = staff.CommissionPercent.ToString();
            lblIsFired.Text           = staff.IsFired       ? "<b><font color=\"red\">Inactive</font></b>" : "Active";
            lblSMSBKs.Text            = staff.EnableDailyReminderSMS   ? "Yes" : "No";
            lblEmailBKs.Text          = staff.EnableDailyReminderEmail ? "Yes" : "No";

            lblIsProvider.Text    = staff.IsProvider    ? "Yes" : "No";
            lblIsPrincipal.Text   = staff.IsPrincipal   ? "Yes" : "No";
            lblIsAdmin.Text       = staff.IsAdmin       ? "Yes" : "No";
            lblIsMasterAdmin.Text = staff.IsMasterAdmin ? "Yes" : "No";
            lblIsStakeholder.Text = staff.IsStakeholder ? "Yes" : "No";

            lblStartDate.Text = staff.StartDate == DateTime.MinValue ? "" : staff.StartDate.ToString("dd-MM-yyyy");
            lblEndDate.Text   = staff.EndDate == DateTime.MinValue ? "" : staff.EndDate.ToString("dd-MM-yyyy");

            lblAddedBy.Font.Bold        = true;
            lblStaffDateAdded.Font.Bold = true;

            txtComments.Enabled   = false;
            txtComments.ForeColor = System.Drawing.Color.Black;



            ddlTitle.Visible      = false;
            txtFirstname.Visible  = false;
            txtMiddlename.Visible = false;
            txtSurname.Visible    = false;
            ddlGender.Visible     = false;
            ddlDOB_Day.Visible    = false;
            ddlDOB_Month.Visible  = false;
            ddlDOB_Year.Visible   = false;

            ddlStartDate_Day.Visible   = false;
            ddlStartDate_Month.Visible = false;
            ddlStartDate_Year.Visible  = false;
            ddlEndDate_Day.Visible     = false;
            ddlEndDate_Month.Visible   = false;
            ddlEndDate_Year.Visible    = false;

            txtLogin.Visible      = false;
            txtPwd.Visible        = false;
            ddlField.Visible      = false;
            chkContractor.Visible = false;
            txtTFN.Visible        = false;
            ddlStatus.Visible     = false;
            chkSMSBKs.Visible     = false;
            chkEmailBKs.Visible   = false;
            //ddlCostCentre.Visible        = false;
            txtProviderNumber.Visible    = false;
            chkIsCommission.Visible      = false;
            txtCommissionPercent.Visible = false;
            chkIsProvider.Visible        = false;
            chkIsPrincipal.Visible       = false;
            chkIsAdmin.Visible           = false;
            chkIsMasterAdmin.Visible     = false;
            chkIsStakeholder.Visible     = false;
        }


        DataTable incList = RegisterStaffDB.GetDataTable_OrganisationsOf(staff.StaffID);

        incList.DefaultView.Sort = "name ASC";
        if (incList.Rows.Count == 0)
        {
            lstClinics.Items.Add(new ListItem("No Clinics Allocated Yet"));
        }
        else
        {
            foreach (DataRowView row in incList.DefaultView)
            {
                lstClinics.Items.Add(new ListItem(row["name"].ToString()));
            }
        }

        UpdateSiteRestrictions();


        btnSubmit.Text    = isEditMode ? "Update Details" : "Edit Details";
        btnCancel.Visible = isEditMode;
    }
Beispiel #5
0
    protected void FillGrid()
    {
        if (!IsValidFormID())
        {
            HideTableAndSetErrorMessage("", "Invalid URL Parameters");
            return;
        }

        Patient patient = PatientDB.GetByID(GetFormID());

        if (patient == null)
        {
            HideTableAndSetErrorMessage(Utilities.IsDev() ? "No patient exists with this ID" : "");
            return;
        }
        patient.Person = PersonDB.GetByID(patient.Person.PersonID);

        lblHeading.Text = Page.Title = "Manage Registrations For :  " + patient.Person.Firstname + " " + patient.Person.Surname;
        this.lnkThisPatient.NavigateUrl = "~/PatientDetailV2.aspx?type=view&id=" + GetFormID().ToString();
        this.lnkThisPatient.Text        = "Back to details for " + patient.Person.FullnameWithoutMiddlename;


        DataTable dt = RegisterPatientDB.GetDataTable_OrganisationsOf(patient.PatientID);

        Session["registerorgtopatient_data"] = dt;


        spn_booking_screen_link.Visible   = UserView.GetInstance().IsAdminView;
        lblSelectOrgBeforeBooking.Visible = dt.Rows.Count == 0 && GetUrlParamType() == UrlParamType.SelectToGoToBookings;
        lnkBookingScreen.Visible          = dt.Rows.Count > 0;
        lnkBookingScreen.NavigateUrl      = String.Format("~/BookingScreenGetPatientOrgsV2.aspx?patient_id={0}", Request["id"]);
        lnkBookingScreen.Text             = "Make Booking";


        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["registerorgtopatient_sortexpression"] != null && Session["registerorgtopatient_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort = Session["registerorgtopatient_sortexpression"].ToString();
                GrdRegistration.DataSource = dataView;
            }
            else
            {
                GrdRegistration.DataSource = dt;
            }


            try
            {
                GrdRegistration.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdRegistration.DataSource = dt;
            GrdRegistration.DataBind();

            int TotalColumns = GrdRegistration.Rows[0].Cells.Count;
            GrdRegistration.Rows[0].Cells.Clear();
            GrdRegistration.Rows[0].Cells.Add(new TableCell());
            GrdRegistration.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdRegistration.Rows[0].Cells[0].Text       = "No Record Found";
        }

        if (hideFotter)
        {
            GrdRegistration.FooterRow.Visible = false;
        }
    }