コード例 #1
0
 protected string GetPhoneNbrs(int entity_id)
 {
     if (Utilities.GetAddressType().ToString() == "Contact")
     {
         Contact[] list   = ContactDB.GetByEntityID(2, entity_id);
         string    result = string.Empty;
         for (int i = 0; i < list.Length; i++)
         {
             result += (i > 0 ? Environment.NewLine : "") + list[i].AddrLine1;
         }
         return(result);
     }
     else if (Utilities.GetAddressType().ToString() == "ContactAus")
     {
         ContactAus[] list   = ContactAusDB.GetByEntityID(2, entity_id);
         string       result = string.Empty;
         for (int i = 0; i < list.Length; i++)
         {
             result += (i > 0 ? Environment.NewLine : "") + list[i].AddrLine1;
         }
         return(result);
     }
     else
     {
         throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: KMerkulov/tasks
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     ContactDB p1 = new ContactDB();
     ContactDB p2 = new ContactDB();
     
     p1.buttonAdd(textBox1.Text, textBox2.Text, textBox3.Text);
 }
コード例 #3
0
ファイル: Patient.cs プロジェクト: nblaurenciana-md/Websites
    public static void UnsubscribeAll(int patientID, string DB)
    {
        SystemVariables sysVariables = SystemVariableDB.GetAll(DB);

        if (sysVariables["AddressType"].Value == "Contact")
        {
            Contact[] emails = ContactDB.GetByEntityID(-1, patientID, 27, false, DB);
            foreach (Contact email in emails)
            {
                ContactDB.UpdateIsBillingIsNonbilling(email.ContactID, email.IsBilling, false, DB);
            }
        }
        else if (sysVariables["AddressType"].Value == "ContactAus")
        {
            ContactAus[] emails = ContactAusDB.GetByEntityID(-1, patientID, 27, false, DB);
            foreach (ContactAus email in emails)
            {
                ContactAusDB.UpdateIsBillingIsNonbilling(email.ContactID, email.IsBilling, false, DB);
            }
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + sysVariables["AddressType"].Value);
        }
    }
コード例 #4
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                if (ContactDB != null)
                {
                    ///Get Role List.
                    cbxRole.ItemsSource = ContactDB.contact_role.Where(a => a.id_company == CurrentSession.Id_Company && a.is_active == true).OrderBy(a => a.name).AsNoTracking().ToList();
                    contactViewSource   = (CollectionViewSource)this.FindResource("contactViewSource");

                    ///Check for ContactID to check if this form is in EDIT mode or NEW mode.
                    if (ContactID > 0)
                    {
                        ///If Contact IsNot Null, then this form is in EDIT MODE. Must add Contact into Context.
                        _contact = ContactDB.contacts.Where(x => x.id_contact == ContactID).FirstOrDefault();
                        ContactDB.contacts.Add(_contact);
                    }
                    else
                    {
                        ///If ContactID is Null, then this form is in NEW MODE. Must create Contact and add into Context.
                        if (ContactDB.contacts.Local.Where(x => x.id_contact == 0).Count() == 0)
                        {
                            _contact = ContactDB.New();
                            ContactDB.contacts.Add(_contact);
                        }
                    }

                    if (IsCustomer)
                    {
                        cbPriceList.ItemsSource = ContactDB.item_price_list.Where(a => a.is_active == true && a.id_company == CurrentSession.Id_Company).OrderBy(a => a.name).AsNoTracking().ToList();
                        _contact.is_customer    = true;
                        _contact.is_supplier    = false;
                        _contact.is_employee    = false;
                    }

                    if (IsSupplier)
                    {
                        cbCostCenter.ItemsSource = ContactDB.app_cost_center.Where(a => a.is_active == true && a.id_company == CurrentSession.Id_Company).OrderBy(a => a.name).AsNoTracking().ToList();
                        _contact.is_supplier     = true;
                        _contact.is_employee     = false;
                        _contact.is_customer     = false;
                    }

                    if (IsEmployee)
                    {
                        _contact.is_employee = true;
                        _contact.is_supplier = false;
                        _contact.is_customer = false;
                    }

                    ///Bring only InMemoria Data.
                    contactViewSource.Source = ContactDB.contacts.Local;
                    contactViewSource.View.MoveCurrentTo(_contact);
                }
            }
        }
コード例 #5
0
    protected void UpdateTables()
    {
        DataTable dt = ContactDB.GetDataTable_ByEntityID(-1, this.EntityID);

        CreateTable(phAddresses, dt.Select("atg_contact_type_group_id=1"), 525, 425);
        CreateTable(phPhoneNums, dt.Select("atg_contact_type_group_id=2"), 450, 275);
        CreateTable(phBedrooms, dt.Select("atg_contact_type_group_id=3"), 450, 275);
        CreateTable(phEmails, dt.Select("atg_contact_type_group_id=4"), 450, 275);
        //this.CreateTableEmails   (dt.Select("ad_contact_type_id=27"));
    }
コード例 #6
0
ファイル: ContactController.cs プロジェクト: bzeller7/SCM
 public ActionResult Create(Contact c)
 {
     if (ModelState.IsValid)
     {
         ContactDB.AddContact(c, context);
         ViewData["Message"] = $"{c.Name} was added!";
         return(RedirectToAction("Create"));
     }
     return(View());
 }
コード例 #7
0
        public void TestEmptyDB()
        {
            var db    = new ContactDB();
            int count = 0;

            db.UpdateStream
            .Subscribe(c => count++);
            db.ShutDown();

            Assert.AreEqual(0, count);
        }
コード例 #8
0
    public static string GetEmailsCommaSepByEntityID(int entityID, bool forBilling, bool forNonBilling)
    {
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            Contact[] contacts = ContactDB.GetByEntityIDs(-1, new int[] { entityID }, 27, -1);
            if (contacts == null || contacts.Length == 0)
            {
                return(null);
            }

            ArrayList emails = new ArrayList();
            foreach (Contact c in contacts)
            {
                if (((forBilling && c.IsBilling) || (forNonBilling && c.IsNonBilling)) && c.AddrLine1.Trim().Length > 0 && Utilities.IsValidEmailAddress(c.AddrLine1.Trim()))
                {
                    emails.Add(c.AddrLine1.Trim());
                }
            }

            if (emails.Count > 0)
            {
                return(string.Join(",", ((string[])emails.ToArray(typeof(string)))));
            }
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            ContactAus[] contacts = ContactAusDB.GetByEntityIDs(-1, new int[] { entityID }, 27, -1);
            if (contacts == null || contacts.Length == 0)
            {
                return(null);
            }

            ArrayList emails = new ArrayList();
            foreach (ContactAus c in contacts)
            {
                if (((forBilling && c.IsBilling) || (forNonBilling && c.IsNonBilling)) && c.AddrLine1.Trim().Length > 0 && Utilities.IsValidEmailAddress(c.AddrLine1.Trim()))
                {
                    emails.Add(c.AddrLine1.Trim());
                }
            }

            if (emails.Count > 0)
            {
                return(string.Join(",", ((string[])emails.ToArray(typeof(string)))));
            }
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        return(null);
    }
コード例 #9
0
        public void AddEmptyStoreLater()
        {
            var db    = new ContactDB();
            int count = 0;

            db.UpdateStream
            .Subscribe(c => count++);
            db.Add(new dummyStore());
            db.ShutDown();

            Assert.AreEqual(0, count);
        }
コード例 #10
0
    public static Contact GetFirstByEntityID(string contact_type_group_id, int entity_id, string contact_type_id = null, bool orderByShippingBeforeBilling = false)
    {
        Contact[] contacts = ContactDB.GetByEntityID(contact_type_group_id, entity_id, contact_type_id, orderByShippingBeforeBilling);

        if (contacts.Length == 0)
        {
            return(null);
        }
        else
        {
            return(contacts[0]);
        }
    }
コード例 #11
0
    protected void InsertEmail(bool PT, bool GP)
    {
        if (txtUpdatePatientID.Text.Length == 0)
        {
            SetErrorMessage("No PT Selected");
            return;
        }


        string[] emails  = null;
        string   refName = null;

        Patient patient = PatientDB.GetByID(Convert.ToInt32(txtUpdatePatientID.Text));

        if (PT)
        {
            emails = ContactDB.GetEmailsByEntityID(patient.Person.EntityID);
        }
        else if (GP)
        {
            PatientReferrer[] patRefs = PatientReferrerDB.GetActiveEPCPatientReferrersOf(patient.PatientID);
            if (patRefs.Length > 0)
            {
                refName = patRefs[0].RegisterReferrer.Referrer.Person.FullnameWithoutMiddlename;
                emails  = ContactDB.GetEmailsByEntityID(patRefs[0].RegisterReferrer.Organisation.EntityID);
            }
        }

        if (emails != null && emails.Length > 0)
        {
            txtEmailTo.Text = string.Join(",", emails);
        }
        else
        {
            if (PT)
            {
                SetErrorMessage("No email address set for " + patient.Person.FullnameWithoutMiddlename + "<br />");
            }
            else if (GP && refName == null)
            {
                SetErrorMessage("No referrer set for " + patient.Person.FullnameWithoutMiddlename + "<br />");
            }
            else if (GP)
            {
                SetErrorMessage("No email set for referrer " + refName + "<br />");
            }

            txtEmailTo.Text = string.Empty;
        }
    }
コード例 #12
0
        public void OneContactSubscribeBeforeAdded()
        {
            var db    = new ContactDB();
            var store = new dummyStore();

            db.Add(store);

            int count = 0;

            db.UpdateStream
            .Subscribe(c => count++);
            store.AddDummyContacts(1);
            db.ShutDown();

            Assert.AreEqual(1, count);
        }
コード例 #13
0
    public static string[] GetFaxesByEntityID(int entityID) // clone from ContactAus.GetEmailsByEntityID(entityID)
    {
        string[] faxes;
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            faxes = Contact.RemoveInvalidPhoneNumbers(ContactDB.GetByEntityID(-1, entityID, 29)).Select(r => Regex.Replace(r.AddrLine1, "[^0-9]", "")).ToArray();
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            faxes = ContactAus.RemoveInvalidPhoneNumbers(ContactAusDB.GetByEntityID(-1, entityID, 29)).Select(r => Regex.Replace(r.AddrLine1, "[^0-9]", "")).ToArray();
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        return(faxes);
    }
コード例 #14
0
    public static string[] GetEmailsByEntityID(int entityID) // clone from ContactAus.GetEmailsByEntityID(entityID)
    {
        string[] emails;
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            emails = Contact.RemoveInvalidEmailAddresses(ContactDB.GetByEntityID(-1, entityID, 27)).Select(r => r.AddrLine1).ToArray();
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            emails = ContactAus.RemoveInvalidEmailAddresses(ContactAusDB.GetByEntityID(-1, entityID, 27)).Select(r => r.AddrLine1).ToArray();
        }
        else
        {
            throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
        }

        return(emails);
    }
コード例 #15
0
    void DeleteContact_Command(object sender, CommandEventArgs e)
    {
        int contactID = Convert.ToInt32(e.CommandArgument);

        ContactDB.UpdateInactive(contactID);

        //
        // the update causes the page with this control to validate to run and I can't find why ... just redirect
        //

        //UpdateTables();
        Response.Redirect(Request.RawUrl);


        // call the main page to redirect ??
        // pass in EventHandler like in InvoiceItemsControl.ascx.cs    ??
        // but need f*****g update code on all sites ffs
    }
コード例 #16
0
        public static async Task <bool> UpdateRecord(ContactDB user)
        {
            var item = await SDKProperty.SQLiteConn.FindAsync <DB.ContactDB>(user.UserId);

            if (item != null && item.UserId != 0)
            {
                await SDKProperty.SQLiteConn.DeleteAsync(item);
            }
            try
            {
                int i = await SDKProperty.SQLiteConn.InsertAsync(user);

                return(i > 0 ? true : false);
            }
            catch (Exception ex)
            {
                SDKClient.logger.Error($"消息处理异常:error:{ex.Message},stack:{ex.StackTrace};\r\n");
                return(false);
            }
        }
コード例 #17
0
    protected void CreateTable(PlaceHolder placeHolder, DataRow[] rows, int width, int height)
    {
        placeHolder.Controls.Clear();
        Table t = new Table();

        placeHolder.Controls.Add(t);
        for (int i = 0; i < rows.Length; i++)
        {
            Contact contact = ContactDB.LoadAll(rows[i]);
            if (contact.FreeText.Trim().Length > 0)
            {
                t.Rows.Add(CreateNewRow(contact, width, height, true, true));
                t.Rows.Add(CreateNewRow(contact, width, height, true, false));
            }
            else
            {
                t.Rows.Add(CreateNewRow(contact, width, height, false, false));
            }
        }
    }
コード例 #18
0
    public static void Delete(int entity_id, bool checkForeignKeys = true)
    {
        if (checkForeignKeys)
        {
            // do NOT delete the "entity" that this is for - that should be done "explicitly" elsewhere
            // but make sure there is no entity that it relies on
            if (SiteDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Site record depends on it ");
            }
            if (PersonDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Person record depends on it ");
            }
            if (OrganisationDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Organisation record depends on it ");
            }
            if (BookingDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Booking record depends on it ");
            }
            if (InvoiceDB.GetCountByEntityID(entity_id) > 0)
            {
                throw new ForeignKeyConstraintException("Can not delete entity_id " + entity_id + " because a ForeignKey Invoice record depends on it ");
            }
        }

        // delete all things associated with the entity
        if (Utilities.GetAddressType().ToString() == "Contact")
        {
            ContactDB.DeleteByEntityID(entity_id);
        }
        else if (Utilities.GetAddressType().ToString() == "ContactAus")
        {
            ContactAusDB.DeleteByEntityID(entity_id);
        }
        NoteDB.DeleteByEntityID(entity_id);

        DBBase.ExecuteNonResult("DELETE FROM Entity WHERE entity_id = " + entity_id.ToString() + "; DBCC CHECKIDENT(Entity,RESEED,1); DBCC CHECKIDENT(Entity);");
    }
コード例 #19
0
        public ActionResult ContactsTable()
        {
            DateTime myDateTime       = DateTime.Now;
            string   sqlformattedDate = myDateTime.ToString("yyyy-MM-dd hh:mm:ss.fff");
            string   batchName        = GetBatchName();
            //Creating a new Batch object
            ContactBatch batch = new ContactBatch();

            batch.BatchName   = batchName;
            batch.CreatedBy   = "System";
            batch.DateCreated = Convert.ToDateTime(sqlformattedDate);

            //calling the post to ContactBatch table--
            int batchID = ContactDB.GetBatchID(batch);

            List <ContactVM> contacts = new List <ContactVM>();

            contacts = (List <ContactVM>)Session["Upload"];
            ContactDB.PostToDatabase(contacts, batchID);
            return(View(contacts));
        }
コード例 #20
0
    protected void btnRegisterReferrerSelectionUpdate_Click(object sender, EventArgs e)
    {
        // can update info ... if needed...
        int newRegisterReferrerID = Convert.ToInt32(registerReferrerID.Value);

        if (newRegisterReferrerID == -1)
        {
            lblReferrerText.Text = "<b>All Referreres</b>";
        }
        else
        {
            RegisterReferrer regRef = RegisterReferrerDB.GetByID(newRegisterReferrerID);
            //lblReferrerText.Text = regRef.Referrer.Person.FullnameWithoutMiddlename;

            string phNumTxt = string.Empty;
            if (Utilities.GetAddressType().ToString() == "Contact")
            {
                Contact[] phNums = ContactDB.GetByEntityID(2, regRef.Organisation.EntityID);
                for (int i = 0; i < phNums.Length; i++)
                {
                    phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " &nbsp;&nbsp; (" + phNums[i].ContactType.Descr + ")";
                }
            }
            else if (Utilities.GetAddressType().ToString() == "ContactAus")
            {
                ContactAus[] phNums = ContactAusDB.GetByEntityID(2, regRef.Organisation.EntityID);
                for (int i = 0; i < phNums.Length; i++)
                {
                    phNumTxt += (i > 0 ? "<br />" : "") + Utilities.FormatPhoneNumber(phNums[i].AddrLine1) + " &nbsp;&nbsp; (" + phNums[i].ContactType.Descr + ")";
                }
            }
            else
            {
                throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
            }

            lblReferrerText.Text = "<b>" + regRef.Referrer.Person.FullnameWithoutMiddlename + "</b> [" + regRef.Organisation.Name + "]" + "<br />" +
                                   (phNumTxt.Length == 0 ? "" : phNumTxt + "<br />"); // put in referrers fax and phone numbers
        }
    }
コード例 #21
0
    protected Tuple <string, string, string, string> GetReferrersEmail()
    {
        if (!IsValidFormID())
        {
            return(null);
        }

        Booking booking = BookingDB.GetByEntityID(GetFormID());

        if (booking == null || booking.Patient == null)
        {
            return(null);
        }

        PatientReferrer[] patientReferrer = PatientReferrerDB.GetActiveEPCPatientReferrersOf(booking.Patient.PatientID);
        if (patientReferrer.Length == 0)
        {
            return(null);
        }

        PatientReferrer  currentPatRegReferrer = patientReferrer[patientReferrer.Length - 1];
        RegisterReferrer curRegReferrer        = currentPatRegReferrer.RegisterReferrer;

        //string refName = curRegReferrer.Referrer.Person.Surname + ", " + curRegReferrer.Referrer.Person.Firstname + " [" + curRegReferrer.Organisation.Name + "]" + " [" + currentPatRegReferrer.PatientReferrerDateAdded.ToString("dd-MM-yyyy") + "]";
        //SetErrorMessage("Name: " + refName);

        string[] emails = ContactDB.GetEmailsByEntityID(currentPatRegReferrer.RegisterReferrer.Organisation.EntityID);
        if (emails.Length == 0)
        {
            return(null);
        }

        string refEmail           = string.Join(",", emails);
        string refName            = (curRegReferrer.Referrer.Person.Title.ID == 0 ? "Dr." : curRegReferrer.Referrer.Person.Title.Descr) + " " + curRegReferrer.Referrer.Person.Surname;
        string bookingOrg         = booking.Organisation.Name;
        string bookingPatientName = booking.Patient.Person.FullnameWithoutMiddlename;

        return(new Tuple <string, string, string, string>(refEmail, refName, bookingOrg, bookingPatientName));
    }
コード例 #22
0
        private void btnSave_MouseUp(object sender, RoutedEventArgs e)
        {
            entity.contact contact = contactViewSource.View.CurrentItem as entity.contact;

            //This is helpful when we want to Automate the search of contact when saving is done.
            if (contact != null)
            {
                ContactName = contact.name;

                if (btnSave_Click != null)
                {
                    btnSave_Click(sender);
                }
            }

            if (ContactDB.SaveChanges() == 0)
            {
                MessageBox.Show("Saving Error");
            }

            btnCancel_MouseDown(null, null);
        }
コード例 #23
0
 public contact()
 {
     InitializeComponent();
     ContactDB = new ContactDB();
 }
コード例 #24
0
    protected void CreateNoteFile(string tmpFilename)
    {
        string header = string.Empty;

        Booking booking = BookingDB.GetByEntityID(GetFormID());

        if (booking != null)
        {
            Site site = SiteDB.GetByID(Convert.ToInt32(Session["SiteID"]));

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

            if (phNums.Length == 0)
            {
                if (Utilities.GetAddressType().ToString() == "Contact")
                {
                    phNums = ContactDB.GetByEntityID(-1, site.EntityID, 34).Select(r => r.AddrLine1).ToArray();
                }
                else if (Utilities.GetAddressType().ToString() == "ContactAus")
                {
                    phNums = ContactAusDB.GetByEntityID(-1, site.EntityID, 34).Select(r => r.AddrLine1).ToArray();
                }
                else
                {
                    throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString());
                }
            }

            string numbers = string.Empty;
            if (phNums.Length > 0)
            {
                numbers += " - TEL " + phNums[0];
            }
            if (phNums.Length > 1)
            {
                numbers += ", " + phNums[1];
            }

            header += site.Name + numbers + Environment.NewLine;
            header += "Clinic:  " + booking.Organisation.Name + Environment.NewLine;

            if (booking.Patient != null)
            {
                header += "Patient:  " + booking.Patient.Person.FullnameWithoutMiddlename + Environment.NewLine;
            }
            if (booking.Offering != null)
            {
                header += "Service:  " + booking.Offering.Name + Environment.NewLine;
            }

            header += "Provider:  " + booking.Provider.Person.FullnameWithoutMiddlename + Environment.NewLine;
            header += "Date of Consultation: " + booking.DateStart.ToString("d MMM yyyy") + Environment.NewLine + Environment.NewLine + "Treatment Note:" + Environment.NewLine;
        }


        System.Collections.ArrayList notesList = new System.Collections.ArrayList();
        foreach (GridViewRow row in GrdNote.Rows)
        {
            Label    lblId    = row.FindControl("lblId") as Label;
            Label    lblText  = row.FindControl("lblText") as Label;
            CheckBox chkPrint = row.FindControl("chkPrint") as CheckBox;

            if (lblId == null || lblText == null || chkPrint == null)
            {
                continue;
            }

            if (chkPrint.Checked)
            {
                notesList.Add(header + lblText.Text.Replace("<br/>", "\n"));
            }
        }

        if (notesList.Count == 0)
        {
            throw new CustomMessageException("Please select at least one note to print.");
        }

        UserView userView     = UserView.GetInstance();
        bool     isAgedCare   = booking != null && booking.Organisation != null ? booking.Organisation.IsAgedCare : userView.IsAgedCareView;
        string   filename     = isAgedCare ? "BlankTemplateAC.docx" : "BlankTemplate.docx";
        string   originalFile = Letter.GetLettersDirectory() + filename;

        if (!System.IO.File.Exists(originalFile))
        {
            throw new CustomMessageException("Template File '" + filename + "' does not exist.");
        }

        string errorString = string.Empty;

        if (!WordMailMerger.Merge(originalFile, tmpFilename, null, null, 0, false, true, (string[])notesList.ToArray(typeof(string)), false, null, out errorString))
        {
            throw new CustomMessageException("Error:" + errorString);
        }
    }
コード例 #25
0
 protected static string GetEmail(Hashtable contactHash, int entityID)
 {
     return(ContactDB.GetEmailsCommaSepByEntityID(contactHash, entityID, false, true));
 }
コード例 #26
0
 public ContactService()
 {
     _contact = new ContactDB();
 }
コード例 #27
0
ファイル: frmDspContact.cs プロジェクト: cyroul82/ABI
 public frmDspContact(ref ContactDB contact)
 {
     InitializeComponent();
     this.contact = contact;
 }
コード例 #28
0
    protected static string SendEmailToPT(bool incSending, DataTable dt, Patient patient, Site site)
    {
        DataRow row = dt.Select("patient_id = " + patient.PatientID)[0];
        string  daysOverdueCommaSep = (string)row["days_overdue_comma_sep"];

        string[] emails = ContactDB.GetEmailsByEntityID(patient.Person.EntityID);
        if (emails.Length == 0)
        {
            return(string.Empty + "[" + daysOverdueCommaSep + "]");
        }


        if (incSending)
        {
            string invoiceIDsCommaSep = (string)row["invoice_ids_comma_sep"];
            int[]  invoiceIDs         = Array.ConvertAll <string, int>(invoiceIDsCommaSep.Split(','), Convert.ToInt32);

            bool   isClinics           = site.SiteType.ID != 2;
            string tmpLettersDirectory = Letter.GetTempLettersDirectory();
            string originalFile        = Letter.GetLettersDirectory() + (isClinics ? @"OverdueInvoiceTemplate.docx" : @"OverdueInvoiceTemplateAC.docx");
            string tmpDir = FileHelper.GetTempDirectoryName(tmpLettersDirectory);
            System.IO.Directory.CreateDirectory(tmpDir);
            string outputFile = tmpDir + "OverdueInvoices.pdf";


            try
            {
                Letter.GenerateOutstandingInvoices(originalFile, outputFile, invoiceIDs, patient.PatientID, -1);

                EmailerNew.SimpleEmail(
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value,
                    ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                    IsDebug ? "*****@*****.**" : string.Join(",", emails),
                    "Overdue Invoices",
                    "Pease find your Invoices attached. <br />Please call us if you do not agree with the Invoice amount stated.<br /><br />Thank you.",
                    true,
                    new string[] { outputFile },
                    false,
                    null,
                    "*****@*****.**"
                    );
            }
            finally
            {
                try { if (System.IO.File.Exists(outputFile))
                      {
                          System.IO.File.Delete(outputFile);
                      }
                }
                catch (Exception) { }

                // delete temp dir
                if (tmpDir != null)
                {
                    try { System.IO.Directory.Delete(tmpDir, true); }
                    catch (Exception) { }
                }
            }
        }

        return(string.Join(", ", emails) + "[" + daysOverdueCommaSep + "]");
    }
コード例 #29
0
 public static Contact SendContactEmail(int IdContact, String Name, String Email, String Objet, String Message)
 {
     return(ContactDB.SendContactEmail(IdContact, Name, Email, Objet, Message));
 }
コード例 #30
0
        private void AddNewUsers(List<User> users)
        {
            User user = new User();
            user = users [counter];
            #if DEBUG
            System.Diagnostics.Debug.WriteLine("Users to add : {0}", user.FirstName + " " + user.LastName);
            #endif

            RunOnUiThread(delegate
            {
                ModalNewContact = new Dialog(this, Resource.Style.lightbox_dialog);
                ModalNewContact.SetContentView(Resource.Layout.ModalNewContacts);

                ((Button)ModalNewContact.FindViewById(Resource.Id.btnAccept)).Click += delegate
                {
                    if (user.Picture.Length > 0)
                    {
                        Contacts.ContactsUtil.contactFilenames.Add(user.AccountID.ToString());
                        System.IO.File.WriteAllBytes(System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, user.AccountID.ToString()),
                                                      user.Picture);
                    }
                    DismissModalDialog();
                    counter++;
                    ContactDB contact = new ContactDB();
                    contact.Blocked = false;
                    contact.ContactAccountID = user.AccountID;
                    contact.OwnerAccountID = AndroidData.CurrentUser.AccountID;
                    contact.ContactUser = user;
                    contacts.Add(contact);
                    if (counter < users.Count)
                        AddNewUsers(users);
                    else
                    {
                        DismissModalDialog();
                        returnToSender();
                    }
                };
                ((Button)ModalNewContact.FindViewById(Resource.Id.btnDecline)).Click += delegate
                {
                    DismissModalDialog();
                    counter++;
                    if (counter < users.Count)
                        AddNewUsers(users);
                    else
                    {
                        DismissModalDialog();
                        returnToSender();
                    }
                };
                ((TextView)ModalNewContact.FindViewById(Resource.Id.txtContactName)).Text = user.FirstName + " " + user.LastName;
                modalImage = ((ImageView)ModalNewContact.FindViewById(Resource.Id.imgContact));
                if (Contacts.ContactsUtil.contactFilenames.Contains(user.AccountID.ToString()))
                {
                    Bitmap bm = BitmapFactory.DecodeFile(System.IO.Path.Combine(wowZapp.LaffOutOut.Singleton.ImageDirectory, user.AccountID.ToString()));
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms);
                    byte[] img = ms.ToArray();
                    displayImage(img, modalImage);
                } else
                {
                    if (user.Picture.Length == 0)
                        RunOnUiThread(() => modalImage.SetBackgroundResource(Resource.Drawable.defaultuserimage));
                    else
                    {
                        if (user.Picture.Length == 0)
                        {
                            LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
                            service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted;
                            service.UserGetImageDataAsync(AndroidData.CurrentUser.AccountID, user.AccountID, new Guid(AndroidData.ServiceAuthToken));
                        } else
                        {
                            Bitmap bm = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.defaultuserimage);
                            System.IO.MemoryStream ms = new System.IO.MemoryStream();
                            bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms);
                            byte[] img = ms.ToArray();
                            displayImage(img, modalImage);
                        }
                    }
                }
                ModalNewContact.Show();
            });
        }
コード例 #31
0
        private void Service_ContactsSearchCompleted(object sender, ContactsSearchCompletedEventArgs e)
        {
            LOLConnectClient service = (LOLConnectClient)sender;
            service.ContactsSearchCompleted -= Service_ContactsSearchCompleted;

            if (null == e.Error)
            {
                LOLConnectSearchResult[] result = e.Result.ToArray();
                List<ContactDB> resultContacts = new List<ContactDB>();

                foreach (LOLConnectSearchResult eachItem in result)
                {
                    if (eachItem.ContactUser.AccountID.Equals(AndroidData.CurrentUser.AccountID))
                    {
                        continue;
                    }

                    ContactDB contactItem = new ContactDB();
                    contactItem.Blocked = false;
                    contactItem.ContactAccountID = eachItem.ContactUser.AccountID;
                    contactItem.OwnerAccountID = AndroidData.CurrentUser.AccountID;
                    contactItem.ContactUser = eachItem.ContactUser;

                    resultContacts.Add(contactItem);
                }
                RunOnUiThread(delegate
                {
                    if (resultContacts.Count == 0)
                    {
                        RunOnUiThread(delegate
                        {
                            GeneralUtils.Alert(context, Application.Context.GetString(Resource.String.commonError),
                                                                Application.Context.GetString(Resource.String.findContactNoContactsFound));
                        });
                    } else
                    {
                        FindContactResultsUtil.contacts = resultContacts;
                        StartActivityForResult(typeof(FindContactResultsActivity), SEARCH);
                    }
                });
            } else
            {
                RunOnUiThread(delegate
                {
                    GeneralUtils.Alert(context, Application.Context.GetString(Resource.String.commonError),
                                                        Application.Context.GetString(Resource.String.errorSearchingContactsByCriteria));
                });
            }
        }
コード例 #32
0
        private void CreateMessagesUI()
        {
            List<UserDB> participants = new List<UserDB>();
            bool moreThanOne = false, isCurrentMe = false;

            if (MessageConversations.clearView)
            {
                listWrapper.RemoveAllViewsInLayout();
                MessageConversations.clearView = false;
            }

            if (Contacts.SelectContactsUtil.selectedContacts.Count != 0)
                Contacts.SelectContactsUtil.selectedContacts.Clear();

            if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList.Count > 1)
            {
                moreThanOne = true;
                for (int m = 0; m < MessageConversations.currentConversationMessages[0].MessageRecipientDBList.Count; ++m)
                {
                    if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid != AndroidData.CurrentUser.AccountID.ToString())
                    {
                        UserDB userDetails = dbm.GetUserWithAccountID(MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid);
                        participants.Add(userDetails);
                        ContactDB contact = new ContactDB();
                        contact.ContactUser = new LOLAccountManagement.User();
                        contact.ContactUser.AccountID = userDetails.AccountID;
                        Contacts.SelectContactsUtil.selectedContacts.Add(contact);
                    } else
                    {
                        UserDB userDetails = UserDB.ConvertFromUser(AndroidData.CurrentUser);
                        participants.Add(userDetails);
                    }
                }
            }

            if (moreThanOne)
            {
                string toReturn = "";
                List<UserDB> sortedList = new List<UserDB>();
                sortedList = participants.OrderBy(s => s.LastName).OrderBy(s => s.FirstName).ToList();
                foreach (UserDB eachItem in sortedList)
                    toReturn += string.Format("{0} {1}, ", eachItem.FirstName, eachItem.LastName);
                int last = toReturn.LastIndexOf(", ");
                toReturn = toReturn.Remove(last);

                using (LinearLayout btnlayout = new LinearLayout (context))
                {
                    btnlayout.Orientation = Android.Widget.Orientation.Vertical;
                    btnlayout.SetGravity(GravityFlags.Center);
                    btnlayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
                    btnlayout.SetPadding((int)ImageHelper.convertDpToPixel(5f, context), 0, (int)ImageHelper.convertDpToPixel(5f, context), (int)ImageHelper.convertDpToPixel(10f, context));

                    using (TextView name = new TextView(context))
                    {
                        name.Text = toReturn;
                        name.SetTextSize(Android.Util.ComplexUnitType.Dip, 18f);
                        name.SetTextColor(Color.Black);
                        RunOnUiThread(() => btnlayout.AddView(name));
                    }

                    using (Button showAll = new Button (context))
                    {
                        showAll.Gravity = GravityFlags.CenterVertical;
                        showAll.Text = Application.Context.Resources.GetString(Resource.String.messageShowAllInConversation);
                        showAll.Click += (object sender, EventArgs e) => {
                            showParticipants(sender, e, participants); };
                        showAll.SetWidth((int)ImageHelper.convertDpToPixel(180f, context));
                        showAll.SetHeight((int)ImageHelper.convertDpToPixel(30f, context));
                        showAll.SetBackgroundResource(Resource.Drawable.button);
                        RunOnUiThread(() => btnlayout.AddView(showAll));
                    }
                    RunOnUiThread(() => listWrapper.AddView(btnlayout));
                }
            }
            myView = null;
            LayoutInflater factory = LayoutInflater.From(this);

            foreach (MessageDB message in MessageConversations.currentConversationMessages)
            {
                if (message != null)
                {
                    if (!moreThanOne)
                        myView = factory.Inflate(Resource.Layout.lstConversation, null);
                    else
                        myView = factory.Inflate(Resource.Layout.lstConversationMulti, null);

                    isCurrentMe = message.FromAccountID != AndroidData.CurrentUser.AccountID ? false : true;
                    LinearLayout shell = new LinearLayout(context);

                    shell.Orientation = Orientation.Horizontal;
                    shell.SetGravity(GravityFlags.CenterVertical);
                    shell.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
                    shell.SetPadding(0, 0, 0, (int)ImageHelper.convertDpToPixel(5f, context));
                    RunOnUiThread(() => shell.AddView(myView));

                    UserDB whoAmI = new UserDB();
                    whoAmI = message.FromAccountID != AndroidData.CurrentUser.AccountID ? dbm.GetUserWithAccountID(message.FromAccountGuid) : UserDB.ConvertFromUser(AndroidData.CurrentUser);

                    ImageView userImage = shell.FindViewById<ImageView>(Resource.Id.imgProfile1);
                    if (Contacts.ContactsUtil.contactFilenames.Contains(message.FromAccountGuid))
                    {
                        using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, message.FromAccountGuid)))
                        {
                            using (MemoryStream ms = new MemoryStream ())
                            {
                                bm.Compress(Bitmap.CompressFormat.Jpeg, 80, ms);
                                byte[] image = ms.ToArray();
                                using (Bitmap myBitmap = ImageHelper.CreateUserProfileImageForDisplay(image, (int)imageSize[0], (int)imageSize[1], this.Resources))
                                {
                                    RunOnUiThread(delegate
                                    {
                                        userImage.SetImageBitmap(myBitmap);
                                    });
                                }
                            }
                        }
                    } else
                    {
                        userImage.LayoutParameters = new LinearLayout.LayoutParams((int)ImageHelper.convertDpToPixel(imageSize [0], context), (int)ImageHelper.convertDpToPixel(imageSize [1], context));
                        userImage.SetScaleType(ImageView.ScaleType.FitXy);
                        userImage.SetImageResource(Resource.Drawable.defaultuserimage);
                    }

                    int left = (int)wowZapp.LaffOutOut.Singleton.ScreenXWidth - (int)ImageHelper.convertDpToPixel(imageSize [0] + 20f, context);
                    int leftOver = (int)wowZapp.LaffOutOut.Singleton.ScreenXWidth - (int)ImageHelper.convertDpToPixel(imageSize [0] + 40f, context);

                    TextView whoIsIt = shell.FindViewById<TextView>(Resource.Id.textNames);
                    whoIsIt.Gravity = !isCurrentMe ? GravityFlags.Left : GravityFlags.Right;
                    whoIsIt.Text = whoAmI.FirstName + " " + whoAmI.LastName;

                    for (int m = 0; m < message.MessageStepDBList.Count; ++m)
                    {
                        if (message.MessageStepDBList [m].StepType == LOLMessageDelivery.MessageStep.StepTypes.Text)
                        {
                            TextView messageText = shell.FindViewById<TextView>(Resource.Id.textMessageBubble);

                            messageText.SetBackgroundResource(message.FromAccountID != AndroidData.CurrentUser.AccountID ? Resource.Drawable.bubblesolidleft :
                                                           Resource.Drawable.bubblesolidright);
                            int lr = (int)ImageHelper.convertDpToPixel(20f, context);
                            int tb = lr / 2;
                            messageText.SetPadding(lr, tb, lr, tb);
                            messageText.SetTextColor(Color.White);
                            messageText.SetTextSize(Android.Util.ComplexUnitType.Dip, 14f);
                            string messager = message.MessageStepDBList [m].MessageText;
                            if (messager.Length > 40)
                                messager = messager.Substring(0, 40) + "...";
                            messageText.Text = messager;
                            messageText.ContentDescription = message.MessageGuid;
                            break;
                        }
                    }

                    TextView messageDate = shell.FindViewById<TextView>(Resource.Id.textDateSent);
                    messageDate.SetTextColor(Color.Black);
                    messageDate.SetTextSize(Android.Util.ComplexUnitType.Dip, 10f);
                    messageDate.Gravity = message.FromAccountID != AndroidData.CurrentUser.AccountID ? GravityFlags.Left : GravityFlags.Right;
                    messageDate.Text = message.MessageSent.ToShortTimeString() + ", " + message.MessageSent.ToShortDateString();

                    TextView txtMessageUnread = shell.FindViewById<TextView>(Resource.Id.txtMessageUnread);
                    txtMessageUnread.Visibility = ViewStates.Gone;

                    LinearLayout messageItems = shell.FindViewById<LinearLayout>(Resource.Id.linearLayout7);
                    messageItems = createMessageBar(messageItems, message, leftOver);

                    RunOnUiThread(delegate
                    {
                        listWrapper.AddView(shell);
                        shell = null;
                    });
                }
            }
            if (progress != null)
                RunOnUiThread(() => progress.Dismiss());
        }
コード例 #33
0
    protected void GrdOrgInvoicesOutstanding_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Email")
        {
            int          organisationID = Convert.ToInt32(e.CommandArgument);
            Organisation org            = OrganisationDB.GetByID(organisationID);
            string[]     emails         = ContactDB.GetEmailsByEntityID(org.EntityID);

            if (emails.Length == 0)
            {
                SetErrorMessage("No email address set for '" + org.Name + "'. Please set one to email invoices to them.");
                return;
            }
            else
            {
                DataTable dt  = Session["orginvoicesoutstanding_data"] as DataTable;
                DataRow   row = dt.Select("organisation_id = " + organisationID)[0];

                string invoiceIDsCommaSep = (string)row["invoice_ids_comma_sep"];
                int[]  invoiceIDs         = Array.ConvertAll <string, int>(invoiceIDsCommaSep.Split(','), Convert.ToInt32);


                string tmpLettersDirectory = Letter.GetTempLettersDirectory();
                string originalFile        = Letter.GetLettersDirectory() + (!UserView.GetInstance().IsAgedCareView ? @"OverdueInvoiceTemplate.docx" : @"OverdueInvoiceTemplateAC.docx");
                string tmpDir = FileHelper.GetTempDirectoryName(tmpLettersDirectory);
                System.IO.Directory.CreateDirectory(tmpDir);
                string outputFile = tmpDir + "OverdueInvoices.pdf";


                try
                {
                    Letter.GenerateOutstandingInvoices(originalFile, outputFile, invoiceIDs, -1, organisationID);

                    EmailerNew.SimpleEmail(
                        ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromEmail"].Value,
                        ((SystemVariables)System.Web.HttpContext.Current.Session["SystemVariables"])["Email_FromName"].Value,
                        string.Join(",", emails),
                        "Overdue Invoices",
                        "Pease find your Invoices attached. <br/>Please call us if you do not agree with the Invoice amount stated.<br /><br />Thank you.",
                        true,
                        new string[] { outputFile },
                        false,
                        null
                        );

                    SetErrorMessage("Invoices Emailed to " + org.Name + " (" + string.Join(",", emails) + ")");
                }
                catch (CustomMessageException cmEx)
                {
                    SetErrorMessage(cmEx.Message);
                }
                catch (Exception ex)
                {
                    SetErrorMessage("", ex.ToString());
                }
                finally
                {
                    try { if (System.IO.File.Exists(outputFile))
                          {
                              System.IO.File.Delete(outputFile);
                          }
                    }
                    catch (Exception) { }

                    // delete temp dir
                    if (tmpDir != null)
                    {
                        try { System.IO.Directory.Delete(tmpDir, true); }
                        catch (Exception) { }
                    }
                }
            }
        }

        if (e.CommandName == "Print")
        {
            int organisationID = Convert.ToInt32(e.CommandArgument);

            DataTable dt  = Session["orginvoicesoutstanding_data"] as DataTable;
            DataRow   row = dt.Select("organisation_id = " + organisationID)[0];

            SetErrorMessage("Org ID: " + row["organisation_id"] + "<br />Invoices: " + row["invoice_ids_comma_sep"]);

            string invoiceIDsCommaSep = (string)row["invoice_ids_comma_sep"];
            int[]  invoiceIDs         = Array.ConvertAll <string, int>(invoiceIDsCommaSep.Split(','), Convert.ToInt32);

            Letter.GenerateOutstandingInvoicesToPrint(Response, invoiceIDs, -1, organisationID, !UserView.GetInstance().IsAgedCareView);
        }

        if (e.CommandName == "SetAllPaid" || e.CommandName == "SetAllWiped")
        {
            try
            {
                int organisationID = Convert.ToInt32(e.CommandArgument);

                DataTable dt  = Session["orginvoicesoutstanding_data"] as DataTable;
                DataRow   row = dt.Select("organisation_id = " + organisationID)[0];

                string invoiceIDsCommaSep = (string)row["invoice_ids_comma_sep"];
                int[]  invoiceIDs         = Array.ConvertAll <string, int>(invoiceIDsCommaSep.Split(','), Convert.ToInt32);


                foreach (int invoiceID in invoiceIDs)
                {
                    Invoice invoice = InvoiceDB.GetByID(invoiceID);
                    if (invoice == null || invoice.IsPaID)
                    {
                        continue;
                    }

                    if (e.CommandName.Equals("SetAllPaid"))
                    {
                        ReceiptDB.Insert(null, 362, invoice.InvoiceID, invoice.TotalDue, Convert.ToDecimal(0.00), false, false, DateTime.MinValue, Convert.ToInt32(Session["StaffID"]));
                        InvoiceDB.UpdateIsPaid(null, invoice.InvoiceID, true);
                    }
                    else if (e.CommandName.Equals("SetAllWiped"))
                    {
                        CreditNoteDB.Insert(invoice.InvoiceID, invoice.TotalDue, string.Empty, Convert.ToInt32(Session["StaffID"]));
                        InvoiceDB.UpdateIsPaid(null, invoice.InvoiceID, true);
                    }
                }

                SetErrorMessage("Invoices Set As " + (e.CommandName.Equals("SetAllPaid") ? "Paid" : "Wiped") + " : " + row["invoice_ids_comma_sep"]);

                GrdOrgInvoicesOutstanding_FillGrid();
            }
            catch (CustomMessageException cmEx)
            {
                SetErrorMessage(cmEx.Message);
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
    }