예제 #1
0
        private void lstContacts_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                var acu = getAccountContactUser(e.Item.Tag as Contact);

                if (e.Item.Checked)
                {
                    IntuneService.AddAccountUser(acu);
                }
                else
                {
                    IntuneService.DeleteAccountUser(acu);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #2
0
        private void lnkForgotPassword_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtEmail.Text.Trim()))
                {
                    MessageBox.Show("Please enter your email address");
                    txtEmail.Focus();
                    return;
                }

                Cursor.Current  = Cursors.WaitCursor;
                lblMessage.Text = "Trying to send email containing your password";
                IntuneService.ForgotPassword(txtEmail.Text);
                lblMessage.Text = "Your password has been emailed.";
                MessageBox.Show("Your password has been emailed.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                lblMessage.Text = "";
                Cursor.Current  = Cursors.Default;
            }
        }
예제 #3
0
        private void loadContacts()
        {
            lstContacts.SelectedIndices.Clear();
            lstContacts.Items.Clear();
            var contacts = IntuneService.GetAllContacts();

            foreach (var contact in contacts)
            {
                var lvi    = lstContacts.Items.Add(contact.Name);
                var intune = contact.HasIntune() ? "Yes" : "No";
                lvi.SubItems.Add(intune);
                lvi.ForeColor = Color.Blue;
                lvi.Font      = new Font(lstContacts.Font, FontStyle.Regular);
                lvi.Tag       = contact;

                if (contact.HasUnreadComments)
                {
                    lvi.ImageIndex = 0;
                }
                else if (contact.HasComments)
                {
                    lvi.ImageIndex = 2;
                }
            }

            if (lstContacts.Items.Count > 0)
            {
                lstContacts.SelectedIndices.Add(0);
            }

            lstContacts.Select();
        }
예제 #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current  = Cursors.WaitCursor;
                lblMessage.Text = "Registering user...";
                var user = new User
                {
                    Name       = txtName.Text.Trim(),
                    Email      = txtEmail.Text.Trim(),
                    Password   = txtPassword.Text.Trim(),
                    AtUserName = txtAtUserName.Text.Trim(),
                    Mobile     = txtMobile.Text.Trim(),
                    CreatedOn  = DateTime.Now,
                };

                if (!user.IsValid())
                {
                    MessageBox.Show("Please enter all the details.");
                    return;
                }

                var contactData = IntuneService.RegisterUser(user);
                lblMessage.Text = "User registeration successful";
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current  = Cursors.WaitCursor;
                lblMessage.Text = "Trying to add this account...";
                var account = new Account
                {
                    Name    = txtName.Text.Trim(),
                    UserId  = Session.CurrentUser.Id,
                    AddedOn = DateTime.Now,
                };

                if (!account.IsValid())
                {
                    MessageBox.Show("Please enter account name");
                    return;
                }

                IntuneService.AddAccount(account);
                lblMessage.Text = "Account added successfully.";
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #6
0
        private void loadContacts(UserAccountRole ofRole)
        {
            lstContacts.ItemChecked -= lstContacts_ItemChecked;
            lstContacts.SelectedIndices.Clear();
            lstContacts.Items.Clear();

            var contacts = IntuneService.GetAllContacts();
            var userIds  = IntuneService.GetAccountUsers(Account.Id, ofRole);

            foreach (var contact in contacts)
            {
                if (!contact.HasIntune())
                {
                    continue;
                }

                var lvi = lstContacts.Items.Add(contact.Name);
                lvi.ForeColor = Color.Blue;
                lvi.Font      = new Font(lstContacts.Font, FontStyle.Regular);
                lvi.Checked   = userIds.Where(u => u == contact.ContactUserId).Count() > 0;
                lvi.Tag       = contact;
            }

            if (lstContacts.Items.Count > 0)
            {
                lstContacts.SelectedIndices.Add(0);
            }

            lstContacts.Select();
            lstContacts.ItemChecked += lstContacts_ItemChecked;
        }
예제 #7
0
        private void loadContacts()
        {
            lstContacts.SelectedIndices.Clear();
            lstContacts.Items.Clear();
            var contacts = IntuneService.GetAllContacts();

            foreach (var contact in contacts)
            {
                if (ShowOnlyIntuneContacts && !contact.HasIntune())
                {
                    continue;
                }

                var lvi    = lstContacts.Items.Add(contact.Name);
                var intune = contact.HasIntune() ? "Yes" : "No";
                lvi.SubItems.Add(intune);
                lvi.ForeColor = Color.Blue;
                lvi.Font      = new Font(lstContacts.Font, FontStyle.Regular);
                lvi.Tag       = contact;
            }

            if (lstContacts.Items.Count > 0)
            {
                lstContacts.SelectedIndices.Add(0);
            }

            lstContacts.Select();
        }
예제 #8
0
        private void loadAccounts()
        {
            lstAccounts.SelectedIndices.Clear();
            lstAccounts.Items.Clear();
            var accounts = IntuneService.GetAllAccounts(_selectedContactId);

            foreach (var account in accounts)
            {
                var lineColor = Color.Blue;

                if (account.Role != UserAccountRole.Owner)
                {
                    lineColor = Color.Brown;
                }

                var lvi = lstAccounts.Items.Add(account.Name);
                lvi.ForeColor = lineColor;
                lvi.Font      = new Font(lstAccounts.Font, FontStyle.Regular);
                lvi.UseItemStyleForSubItems = false;

                var lvsi = lvi.SubItems.Add(account.Role.ToString().Substring(0, 1));
                lvsi.ForeColor = lineColor;
                lvsi.Font      = new Font(lstAccounts.Font, FontStyle.Regular);

                var txn = account.Balance == 0 ? account.HasEntries ? "++" : "NA"
                                    : account.Balance > 0 ? getBalanceTitle(account, "Rbl") : getBalanceTitle(account, "Pbl");

                lvsi = lvi.SubItems.Add(txn);
                var balanceColor = getBalanceColor(account);
                lvsi.ForeColor = account.Balance == 0 ? lineColor : balanceColor;
                lvsi.Font      = new Font(lstAccounts.Font, FontStyle.Regular);

                lvsi           = lvi.SubItems.Add(Math.Abs(account.Balance).ToString("C2", CultureInfo.CurrentCulture));
                lvsi.ForeColor = account.Balance == 0 ? lineColor : balanceColor;
                lvsi.Font      = new Font(lstAccounts.Font, FontStyle.Regular);

                lvi.Tag = account;
                if (account.HasUnreadComments)
                {
                    lvi.ImageIndex = 0;
                }
                else if (account.HasComments)
                {
                    lvi.ImageIndex = 2;
                }
            }

            if (lstAccounts.Items.Count > 0)
            {
                lstAccounts.SelectedIndices.Add(0);
            }

            lstAccounts.Select();
        }
예제 #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                Contact contact = null;

                if (Contact == null)
                {
                    lblMessage.Text   = "Trying to add this contact...";
                    contact           = new Contact();
                    contact.UserId    = Session.CurrentUser.Id;
                    contact.CreatedOn = DateTime.Now;
                }
                else
                {
                    lblMessage.Text = "Trying to save this contact...";
                    contact         = Contact;
                }

                fillContact(contact);

                if (!contact.IsValid())
                {
                    MessageBox.Show("Please enter all the details.");
                    return;
                }

                if (Contact == null)
                {
                    IntuneService.AddContact(contact);
                    lblMessage.Text = "Contact added successfully.";
                }
                else
                {
                    IntuneService.UpdateContact(contact);
                    lblMessage.Text = "Contact saved successfully.";
                }

                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #10
0
        public FComment GetContactCommentForm(Contact contact)
        {
            FComment instance = null;
            var      key      = composeKey(CommentType.Contact, contact.ContactUserId);
            var      found    = _instances.TryGetValue(key, out instance);

            if (found)
            {
                return(instance);
            }

            instance        = getFormInstance();
            instance.ToUser = IntuneService.GetUserById(contact.ContactUserId);
            _instances.Add(key, instance);
            return(instance);
        }
예제 #11
0
        private void markAsAccountHasUnreadComment(ChatMessage chatMessage)
        {
            foreach (ListViewItem lvi in lstAccounts.Items)
            {
                var account = lvi.Tag as Account;
                if (account.Id == chatMessage.AccountId)
                {
                    lvi.ImageIndex = 1;
                    if (!account.HasUnreadComments)
                    {
                        IntuneService.MarkAccountCommentAsUnread(chatMessage.AccountId, Session.CurrentUser.Id);
                    }

                    return;
                }
            }
        }
예제 #12
0
        private void FComment_Load(object sender, EventArgs e)
        {
            try
            {
                this.Icon = Resources.IntuneComment;
                Comment[] comments = null;
                this.Text = Session.GetFormTitle();

                if (Entry != null)
                {
                    lblHead.Text  = string.Format("{0} Entry", Account.Name);
                    lblTitle.Text = string.Format("{0}:\n{1} on {2}\nof Qty: {3} and {4}", Account.Name, Entry.Notes, Entry.TxnDate.ToShortDateString(), Entry.Quantity, Entry.Amount.ToString("C2", CultureInfo.CurrentCulture));
                    comments      = IntuneService.GetEntryComments(Entry.Id, ByUser.Id);
                }
                else if (Account != null)
                {
                    //TODO: could display profile and photo and can display summary of a/c
                    lblHead.Text  = Account.Name;
                    lblTitle.Text = string.Format("Comments on\n{0}", Account.Name);
                    comments      = IntuneService.GetAccountComments(Account.Id, ByUser.Id);
                }
                else
                {
                    //TODO: could display profile and photo etc.
                    lblHead.Text  = string.Format("{0}@Intune", ToUser.Name);
                    lblTitle.Text = string.Format("Conversation between you and {0}", ToUser.Name);
                    comments      = IntuneService.GetContactComments(ByUser.Id, ToUser.Id);
                }

                renderComments(comments);
                rtbComments.ScrollToCaret();
                txtComment.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            listView1.Columns.Clear();
            listView1.Groups.Clear();
            listView1.MultiSelect   = true;
            listView1.FullRowSelect = true;
            listView1.View          = View.Details;
            //listView1.GridLines = true;
            listView1.HeaderStyle = ColumnHeaderStyle.None;
            listView1.Groups.Clear();
            listView1.Groups.Clear();

            listView1.Columns.Add("", 19);
            listView1.Columns.Add("From", 100, HorizontalAlignment.Right);
            listView1.Columns.Add("Message", 200);
            listView1.Columns.Add("At", 60);

            var comments = IntuneService.GetAccountComments(1, 2);

            foreach (var comment in comments)
            {
                var name = comment.ByUserName == "Ashok Guduru" ? "Me:" : comment.ByUserName + ":";

                var lvi = listView1.Items.Add("");
                lvi.ImageIndex = 9;
                lvi.UseItemStyleForSubItems = false;

                var lvsi = lvi.SubItems.Add(name);
                lvsi.Font      = new Font(listView1.Font, FontStyle.Bold);
                lvsi.ForeColor = name == "Me:" ? Color.Blue : Color.Purple;

                lvsi           = lvi.SubItems.Add(comment.CommentText);
                lvsi.Font      = new Font(listView1.Font, FontStyle.Regular);
                lvsi.ForeColor = Color.Black;

                lvsi           = lvi.SubItems.Add(comment.DateTimeStamp.ToString("hh:mm:tt"));
                lvsi.Font      = new Font("Tahoma", 7.0F, FontStyle.Regular);
                lvsi.ForeColor = Color.Green;
            }
        }
예제 #14
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current  = Cursors.WaitCursor;
                lblMessage.Text = "Trying to add this entry...";
                var txnType = (TxnType)cmbTxnType.SelectedValue;
                var entry   = new Entry
                {
                    UserId    = Session.CurrentUser.Id,
                    AccountId = Account.Id,
                    Notes     = txtNotes.Text.Trim(),
                    TxnType   = txnType,
                    TxnDate   = dtpTxnDate.Value,
                    Quantity  = Convert.ToDouble(txtQuantity.Text),
                    Amount    = Convert.ToDecimal(txtAmount.Text),
                    VoidId    = 0
                };

                if (!entry.IsValid())
                {
                    MessageBox.Show("Please enter details");
                    lblMessage.Text = "";
                    return;
                }

                IntuneService.AddAccountEntry(entry);
                lblMessage.Text = "Entry added successfully.";
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #15
0
        private void addComment()
        {
            if (string.IsNullOrWhiteSpace(txtComment.Text))
            {
                return;
            }

            var comment = new Comment
            {
                ByUserId      = ByUser.Id,
                ToUserId      = ToUser == null ? 0 : ToUser.Id,
                AccountId     = Account == null ? 0 : Account.Id,
                EntryId       = Entry == null ? 0 : Entry.Id,
                CommentText   = txtComment.Text,
                DateTimeStamp = DateTime.Now,
            };

            comment = IntuneService.AddComment(comment);

            var chatMessage = new ChatMessage
            {
                ByEmail       = ByUser.Email,
                ByName        = ByUser.Name,
                ToEmail       = ToUser == null ? "" : ToUser.Email,
                ToName        = ToUser == null ? "" : ToUser.Name,
                Text          = comment.CommentText,
                ByUserId      = comment.ByUserId,
                ToUserId      = comment.ToUserId,
                AccountId     = comment.AccountId,
                EntryId       = comment.EntryId,
                DateTimeStamp = comment.DateTimeStamp,
            };

            Session.CommentFormManager.SendMessage(chatMessage);
            DisplayComment(chatMessage);
            txtComment.Text = "";
            txtComment.Focus();
        }
예제 #16
0
        private void lnkVoidEntry_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (!shouldVoidEntry())
                {
                    return;
                }

                Cursor.Current = Cursors.WaitCursor;
                var entry = lstEntries.SelectedItems[0].Tag as Entry;

                var voidEntry = new Entry
                {
                    UserId    = Session.CurrentUser.Id,
                    AccountId = entry.AccountId,
                    Notes     = composeVoidNotes(entry),
                    TxnType   = makeVoidTxnType(entry),
                    TxnDate   = DateTime.Now.Date,
                    Quantity  = entry.Quantity,
                    Amount    = entry.Amount,
                    VoidId    = entry.Id,
                };

                IntuneService.AddAccountEntry(voidEntry);
                refreshList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #17
0
        private void lnkAddContact_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                var f      = new FContacts();
                var result = f.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }

                Cursor.Current = Cursors.WaitCursor;
                var contacts = f.SelectedContacts;
                foreach (var contact in contacts)
                {
                    var acu = new AccountContactUser
                    {
                        AccountId = Account.Id,
                        ContactId = contact.Id,
                        UserId    = Session.CurrentUser.Id
                    };
                    IntuneService.AddAccountContact(acu);
                }

                refreshList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #18
0
        private void loadContacts()
        {
            lstContacts.SelectedIndices.Clear();
            lstContacts.Items.Clear();
            var contacts = IntuneService.GetAccountContacts(Session.CurrentUser.Id, Account.Id);

            foreach (var contact in contacts)
            {
                var lvi = lstContacts.Items.Add(contact.Name);
                lvi.ForeColor = Color.Blue;
                lvi.Font      = new Font(lstContacts.Font, FontStyle.Regular);
                var intune = contact.HasIntune() ? "Yes" : "No";
                var lvsi   = lvi.SubItems.Add(intune);
                lvi.Tag = contact;
            }

            if (lstContacts.Items.Count > 0)
            {
                lstContacts.SelectedIndices.Add(0);
            }

            lnkComment.Visible = lstContacts.Items.Count > 0;
            lstContacts.Select();
        }
예제 #19
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current  = Cursors.WaitCursor;
                lblMessage.Text = "Trying to login to Intune...";
                var email    = txtEmail.Text.Trim();
                var password = txtPassword.Text.Trim();
                if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
                {
                    MessageBox.Show("Please enter your login credentials");
                    return;
                }

                var user = IntuneService.Login(email, password);
                Session.CurrentUser = user;
                var msg = string.Format("{0} login successful", user.Name);
                lblMessage.Text = msg;
                var f = new FMain();
                this.Hide();
                f.ShowDialog();
                txtEmail.Text       = "";
                txtPassword.Text    = "";
                Session.CurrentUser = null;
                this.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                lblMessage.Text = "";
                Cursor.Current  = Cursors.Default;
            }
        }
예제 #20
0
        private void loadEntries()
        {
            lstEntries.SelectedIndices.Clear();
            lstEntries.Items.Clear();

            double totalCreditQuantity = 0.00;
            double totalDebitQuantity  = 0.00;

            decimal totalCreditAmount = 0.00M;
            decimal totalDebitAmount  = 0.00M;

            var entries = IntuneService.GetAccountEntries(Account.Id);

            foreach (var entry in entries)
            {
                var lineColor = Color.Blue;

                if (entry.VoidId > 0)
                {
                    lineColor = Color.DimGray;
                }
                else if (entry.TxnType == TxnType.Paid || entry.TxnType == TxnType.Issu)
                {
                    lineColor = Account.Role == UserAccountRole.Collaborator ? Color.Red : Color.Green;
                }
                else if (entry.TxnType == TxnType.Rcvd)
                {
                    lineColor = Account.Role == UserAccountRole.Collaborator ? Color.Green : Color.Red;
                }

                var lvi = lstEntries.Items.Add(entry.TxnDate.ToString("dd-MM-yy"));
                lvi.ForeColor = lineColor;
                lvi.Font      = new Font(lstEntries.Font, FontStyle.Regular);

                var lvsi = lvi.SubItems.Add(getTxnType(entry));
                lvsi    = lvi.SubItems.Add(entry.Quantity.ToString("#0"));
                lvsi    = lvi.SubItems.Add(entry.Amount.ToString("C2", CultureInfo.CurrentCulture));
                lvi.Tag = entry;

                if (entry.TxnType == TxnType.Paid || entry.TxnType == TxnType.Issu)
                {
                    totalCreditAmount   += entry.Amount;
                    totalCreditQuantity += entry.Quantity;
                }
                else
                {
                    totalDebitAmount   += entry.Amount;
                    totalDebitQuantity += entry.Quantity;
                }
            }

            if (lstEntries.Items.Count > 0)
            {
                lstEntries.SelectedIndices.Add(0);
                var balanceAmount   = totalCreditAmount - totalDebitAmount;
                var balanceQuantity = totalCreditQuantity - totalDebitQuantity;
                addEntryRow("Total:", getTotalsTxnType("Paid"), totalCreditQuantity, totalCreditAmount, Color.Black, FontStyle.Regular);
                addEntryRow("Total:", getTotalsTxnType("Rcvd"), totalDebitQuantity, totalDebitAmount, Color.Purple, FontStyle.Regular);
                var balanceTitle = balanceAmount == 0 ? "Zero" : balanceAmount > 0 ? getBalanceTitle("Rcvbl") : getBalanceTitle("Paybl");
                addEntryRow("Balance:", balanceTitle, balanceQuantity, Math.Abs(balanceAmount), Color.Blue, FontStyle.Regular);
            }

            lnkComment.Visible   = lstEntries.Items.Count > 0;
            lnkVoidEntry.Visible = lstEntries.Items.Count > 0 &&
                                   (Account.Role == UserAccountRole.Owner || Account.Role == UserAccountRole.Impersonator);
            lstEntries.Select();
        }