コード例 #1
0
        public void Menu()
        {
            int flag = 1;

            while (flag != 0)
            {
                Console.WriteLine("\nType keywords to perform Action\n Add \tDisplay \tUpdate \tSearch \tDelete \tExit");
                string choice = Console.ReadLine();
                switch (choice.ToLower())
                {
                case "add":
                    contactDB.Insert(ContactDetails());
                    break;

                case "display":
                    contactDB.Display();
                    break;

                case "update": Console.WriteLine("Enter the name whose Constact is to be Updated");
                    contactDB.Update(Console.ReadLine());
                    break;

                case "search": contactDB.SearchByName(Console.ReadLine());
                    break;

                case "delete": contactDB.Delete(Console.ReadLine());
                    break;

                case "exit":
                    flag = 0;
                    break;

                default: Console.WriteLine("Enter Proper KeyWord");
                    break;
                }
            }
        }
コード例 #2
0
 public ArrayList InsertContact(Contact newContact)
 {
     return(contact.Insert(newContact));
 }
コード例 #3
0
    protected int AddEmailIfNotExists(Patient patient, int siteID, string email)
    {
        // add email if different from existing

        int email_id = -1;

        string[] emails = ContactDB.GetEmailsByEntityID(patient.Person.EntityID);

        bool emailAlreadyExists = false;

        foreach (string e in emails)
        {
            if (e == email)
            {
                emailAlreadyExists = true;
            }
        }

        if (!emailAlreadyExists)
        {
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                if (email.Length > 0)
                {
                    email_id = ContactDB.Insert(patient.Person.EntityID,
                                                27,
                                                "",
                                                email,
                                                string.Empty,
                                                -1,
                                                -1,
                                                -1,
                                                Convert.ToInt32(siteID),
                                                true,
                                                true);
                }
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                if (email.Length > 0)
                {
                    email_id = ContactAusDB.Insert(patient.Person.EntityID,
                                                   27,
                                                   "",
                                                   email,
                                                   string.Empty,
                                                   string.Empty,
                                                   -1,
                                                   -1,
                                                   -1,
                                                   Convert.ToInt32(siteID),
                                                   true,
                                                   true);
                }
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }
        }

        return(email_id);
    }
コード例 #4
0
    protected int AddPhoneNbrIfNotExists(Patient patient, int siteID, string phoneNumber)
    {
        // add phone number if different from existing

        int phone_id = -1;

        string[] phoneNumbers;
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            phoneNumbers = ContactDB.GetByEntityID(2, patient.Person.EntityID, -1).Select(r => r.AddrLine1).ToArray();
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            phoneNumbers = ContactAusDB.GetByEntityID(2, patient.Person.EntityID, -1).Select(r => r.AddrLine1).ToArray();
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        bool phoneNumberAlreadyExists = false;

        foreach (string p in phoneNumbers)
        {
            if (Regex.Replace(p, "[^0-9]", "") == Regex.Replace(phoneNumber, "[^0-9]", ""))
            {
                phoneNumberAlreadyExists = true;
            }
        }

        if (!phoneNumberAlreadyExists)
        {
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                if (phoneNumber.Length > 0)
                {
                    phone_id = ContactDB.Insert(patient.Person.EntityID,
                                                Convert.ToInt32(ddlPhoneNumberType.SelectedValue),
                                                "",
                                                System.Text.RegularExpressions.Regex.Replace(phoneNumber, "[^0-9]", ""),
                                                string.Empty,
                                                -1,
                                                -1,
                                                -1,
                                                siteID,
                                                true,
                                                true);
                }
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                if (phoneNumber.Length > 0)
                {
                    phone_id = ContactAusDB.Insert(patient.Person.EntityID,
                                                   Convert.ToInt32(ddlPhoneNumberType.SelectedValue),
                                                   "",
                                                   System.Text.RegularExpressions.Regex.Replace(phoneNumber, "[^0-9]", ""),
                                                   string.Empty,
                                                   string.Empty,
                                                   -1,
                                                   -1,
                                                   -1,
                                                   siteID,
                                                   true,
                                                   true);
                }
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }
        }

        return(phone_id);
    }
コード例 #5
0
 public void Insert(Contact contact)
 {
     objDb.Insert(contact);
 }
コード例 #6
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        // need to be able to roll back .. so keep id's same as invoice

        int  person_id      = -1;
        int  referrer_id    = -1;
        int  new_org_id     = 0;
        bool referrer_added = false;

        int  address_id     = -1;
        int  phone_id1      = -1;
        int  phone_id2      = -1;
        int  email_id       = -1;
        bool contacts_added = false;

        try
        {
            // add referrer
            if (lblId.Text == "-1") // add new referrer
            {
                Staff loggedInStaff = StaffDB.GetByID(Convert.ToInt32(Session["StaffID"]));
                person_id   = PersonDB.Insert(loggedInStaff.Person.PersonID, Convert.ToInt32(ddlTitle.SelectedValue), Utilities.FormatName(txtFirstname.Text), Utilities.FormatName(txtMiddlename.Text), Utilities.FormatName(txtSurname.Text), "", ddlGender.SelectedValue, new DateTime(1900, 1, 1));
                referrer_id = ReferrerDB.Insert(person_id);
            }
            else  // set existing referrer
            {
                referrer_id = Convert.ToInt32(lblId.Text);
            }


            // get org (or add new org)
            int org_id = 0;
            if (orgsListRow.Visible)
            {
                org_id = Convert.ToInt32(ddlOrgsList.SelectedValue);
            }
            else
            {
                org_id = new_org_id = OrganisationDB.InsertExtOrg(191, txtOrgName.Text, txtOrgACN.Text, txtOrgABN.Text, false, false, "", txtOrgComments.Text);

                // add contact info

                Organisation org = OrganisationDB.GetByID(org_id);

                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    if (txtAddressAddrLine1.Text.Trim().Length > 0 || txtAddressAddrLine2.Text.Trim().Length > 0)
                    {
                        address_id = ContactDB.Insert(org.EntityID,
                                                      Convert.ToInt32(ddlAddressContactType.SelectedValue),
                                                      txtAddressFreeText.Text,
                                                      txtAddressAddrLine1.Text,
                                                      txtAddressAddrLine2.Text,
                                                      Convert.ToInt32(ddlAddressAddressChannel.SelectedValue),
                                                      //Convert.ToInt32(ddlAddressSuburb.SelectedValue),
                                                      Convert.ToInt32(suburbID.Value),
                                                      Convert.ToInt32(ddlAddressCountry.SelectedValue),
                                                      Convert.ToInt32(Session["SiteID"]),
                                                      true,
                                                      true);
                    }

                    if (txtPhoneNumber1.Text.Trim().Length > 0)
                    {
                        phone_id1 = ContactDB.Insert(org.EntityID,
                                                     Convert.ToInt32(ddlPhoneNumber1.SelectedValue),
                                                     txtPhoneNumber1FreeText.Text,
                                                     System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber1.Text, "[^0-9]", ""),
                                                     string.Empty,
                                                     -1,
                                                     -1,
                                                     -1,
                                                     Convert.ToInt32(Session["SiteID"]),
                                                     true,
                                                     true);
                    }

                    if (txtPhoneNumber2.Text.Trim().Length > 0)
                    {
                        phone_id2 = ContactDB.Insert(org.EntityID,
                                                     Convert.ToInt32(ddlPhoneNumber2.SelectedValue),
                                                     txtPhoneNumber2FreeText.Text,
                                                     System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber2.Text, "[^0-9]", ""),
                                                     string.Empty,
                                                     -1,
                                                     -1,
                                                     -1,
                                                     Convert.ToInt32(Session["SiteID"]),
                                                     true,
                                                     true);
                    }

                    if (txtEmailAddrLine1.Text.Trim().Length > 0)
                    {
                        email_id = ContactDB.Insert(org.EntityID,
                                                    Convert.ToInt32(ddlEmailContactType.SelectedValue),
                                                    "",
                                                    txtEmailAddrLine1.Text,
                                                    string.Empty,
                                                    -1,
                                                    -1,
                                                    -1,
                                                    Convert.ToInt32(Session["SiteID"]),
                                                    true,
                                                    true);
                    }
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    if (txtAddressAddrLine1.Text.Trim().Length > 0 || txtAddressAddrLine2.Text.Trim().Length > 0)
                    {
                        address_id = ContactAusDB.Insert(org.EntityID,
                                                         Convert.ToInt32(ddlAddressContactType.SelectedValue),
                                                         txtAddressFreeText.Text,
                                                         txtAddressAddrLine1.Text,
                                                         txtAddressAddrLine2.Text,
                                                         txtStreet.Text,
                                                         Convert.ToInt32(ddlAddressAddressChannelType.SelectedValue),
                                                         //Convert.ToInt32(ddlAddressSuburb.SelctedValue),
                                                         Convert.ToInt32(suburbID.Value),
                                                         Convert.ToInt32(ddlAddressCountry.SelectedValue),
                                                         Convert.ToInt32(Session["SiteID"]),
                                                         true,
                                                         true);
                    }

                    if (txtPhoneNumber1.Text.Trim().Length > 0)
                    {
                        phone_id1 = ContactAusDB.Insert(org.EntityID,
                                                        Convert.ToInt32(ddlPhoneNumber1.SelectedValue),
                                                        txtPhoneNumber1FreeText.Text,
                                                        System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber1.Text, "[^0-9]", ""),
                                                        string.Empty,
                                                        string.Empty,
                                                        -1,
                                                        -1,
                                                        -1,
                                                        Convert.ToInt32(Session["SiteID"]),
                                                        true,
                                                        true);
                    }

                    if (txtPhoneNumber2.Text.Trim().Length > 0)
                    {
                        phone_id2 = ContactAusDB.Insert(org.EntityID,
                                                        Convert.ToInt32(ddlPhoneNumber2.SelectedValue),
                                                        txtPhoneNumber2FreeText.Text,
                                                        System.Text.RegularExpressions.Regex.Replace(txtPhoneNumber2.Text, "[^0-9]", ""),
                                                        string.Empty,
                                                        string.Empty,
                                                        -1,
                                                        -1,
                                                        -1,
                                                        Convert.ToInt32(Session["SiteID"]),
                                                        true,
                                                        true);
                    }

                    if (txtEmailAddrLine1.Text.Trim().Length > 0)
                    {
                        email_id = ContactAusDB.Insert(org.EntityID,
                                                       Convert.ToInt32(ddlEmailContactType.SelectedValue),
                                                       "",
                                                       txtEmailAddrLine1.Text,
                                                       string.Empty,
                                                       string.Empty,
                                                       -1,
                                                       -1,
                                                       -1,
                                                       Convert.ToInt32(Session["SiteID"]),
                                                       true,
                                                       true);
                    }
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }
            }

            contacts_added = true;

            // join association
            RegisterReferrerDB.Insert(org_id, referrer_id, txtProviderNumber.Text, chkIsReportEveryVisit.Checked, chkIsBatchSendAllPatientsTreatmentNotes.Checked);
            referrer_added = true;


            if (GetUrlIsPopup())
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script language=javascript>window.returnValue=false;self.close();</script>");
            }
            else
            {
                Response.Redirect("~/ReferrerList_DoctorClinicV2.aspx?surname_search=" + Utilities.FormatName(txtSurname.Text) + "&surname_starts_with=1", false);
                return;
            }
        }
        catch (Exception)
        {
            // roll back - backwards of creation order

            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                ContactDB.Delete(address_id);
                ContactDB.Delete(phone_id1);
                ContactDB.Delete(phone_id2);
                ContactDB.Delete(email_id);
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                ContactAusDB.Delete(address_id);
                ContactAusDB.Delete(phone_id1);
                ContactAusDB.Delete(phone_id2);
                ContactAusDB.Delete(email_id);
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }

            OrganisationDB.Delete(new_org_id);
            ReferrerDB.Delete(referrer_id);
            PersonDB.Delete(person_id);

            throw;
        }
    }