Exemple #1
0
        private void RefreshMemberListBox()
        {
            listBoxAllMemberNames.Items.Clear();

            try
            {
                using (var context = new LorikeetAppEntities())
                {
                    var getAllMemberName = (from m in context.Members
                                            select m).ToList();

                    foreach (var m in getAllMemberName)
                    {
                        if ((m.FirstName + " " + m.Surname).ToLower().StartsWith(textBoxMNameToChangeTo.Text.ToLower()))
                        {
                            listBoxAllMemberNames.Items.Add(m.FirstName + " " + m.Surname);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
        public void CloseForm()
        {
            try
            {
                DialogResult dr = new DialogResult();
                dr = MessageBox.Show("Do you want to save the Excel File before you quit", "Warning", MessageBoxButtons.YesNoCancel);

                if (dr == DialogResult.Yes)
                {
                    spreadsheetControl1.SaveDocument(fileName, DocumentFormat.OpenXml);
                    saved = true;
                    this.Close();
                }
                else if (dr == DialogResult.No)
                {
                    saved = true;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                saved = false;
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
Exemple #3
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                using (var context = new LorikeetAppEntities())
                {
                    var validLogin = (from s in context.Staffs
                                      join l in context.Logins on s.LoginID equals l.LoginID
                                      where l.LoginName == textBoxUsername.Text && l.LoginPass == textBoxPassword.Text
                                      select s).DefaultIfEmpty().First();

                    if (validLogin != null)
                    {
                        DialogResult = DialogResult.OK;
                        this.staffID = validLogin.StaffID;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Not a Valid Login and Password");
                        DialogResult = DialogResult.Cancel;
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
        private void ImportFile(string fullDirectory)
        {
            try
            {
                var importFileDialog = new OpenFileDialog();
                importFileDialog.InitialDirectory = @"C:\";
                importFileDialog.Title            = "Import Files";
                importFileDialog.CheckFileExists  = true;
                importFileDialog.CheckPathExists  = true;
                importFileDialog.Filter           = "Word Documents (*.docx)|*.docx|Excel Documents (*.xlsx)|*.xlsx|PDF Documents (*.pdf)|*.pdf|All Files (*.*)|*.*";
                importFileDialog.FilterIndex      = 4;
                importFileDialog.Multiselect      = true;

                DialogResult dr = new DialogResult();
                dr = importFileDialog.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    foreach (String file in importFileDialog.FileNames)
                    {
                        File.Copy(file, fullDirectory + "\\" + Path.GetFileName(file));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
Exemple #5
0
        private void CenterOnPosition(string addressText)
        {
            try
            {
                if (addressText.Count() > 5)
                {
                    var request = new GeocodingRequest
                    {
                        Key = MiscStuff.googleApiKey,
                        Address = addressText
                    };

                    var result = GoogleMaps.Geocode.Query(request);

                    if (result.Status == Status.Ok)
                    {
                        var geocodeResult = result.Results.FirstOrDefault();
                        if (geocodeResult != null)
                        {
                            textBoxAddress.Text = addressText;
                            gmap.Position = new PointLatLng(geocodeResult.Geometry.Location.Latitude, geocodeResult.Geometry.Location.Longitude);
                        }
                    }
                }
                else
                {
                    gmap.Position = new PointLatLng(perthLatitude, perthLongitude);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
        private void RefreshUserListBox()
        {
            try
            {
                using (var context = new LorikeetAppEntities())
                {
                    listBoxUsers.Items.Clear();

                    var usernames = (from log in context.Logins
                                     join staff in context.Staffs on log.LoginID equals staff.LoginID
                                     select new { staff, log }).ToList();

                    string staffName = MiscStuff.GetStaffName(staffID);

                    foreach (var name in usernames)
                    {
                        if (access == 10)
                        {
                            listBoxUsers.Items.Add(name.staff.StaffName);
                        }
                        else if ((access == 8 && staffName.Equals(name.staff.StaffName)) || name.log.Access <= 6)
                        {
                            listBoxUsers.Items.Add(name.staff.StaffName);
                        }
                        else if (access == 6 && staffName.Equals(name.staff.StaffName))
                        {
                            listBoxUsers.Items.Add(name.staff.StaffName);
                        }
                    }
                }
            }
            catch { }
        }
Exemple #7
0
        private void RefreshMembers()
        {
            listBoxControlMembers.Items.Clear();
            listBoxControlMembersToAdd.Items.Clear();

            try
            {
                if (members != null)
                {
                    foreach (var m in members)
                    {
                        if ((m.FirstName + " " + m.Surname).ToLower().StartsWith(textBoxMemberFilter.Text.ToLower()))
                        {
                            listBoxControlMembers.Items.Add((m.FirstName + " " + m.Surname));
                        }
                    }
                }

                if (membersToAdd != null)
                {
                    foreach (var m in membersToAdd)
                    {
                        listBoxControlMembersToAdd.Items.Add((m.FirstName + " " + m.Surname));
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
Exemple #8
0
        private void GetAttendanceNumber()
        {
            try
            {
                DateTime todaysDate;

                if (DateTime.TryParse(dateEditEditAttendance.Text, out todaysDate))
                {
                    using (var context = new LorikeetAppEntities())
                    {
                        var attendanceNumber = (from a in context.AttendanceNumbers
                                                where DbFunctions.TruncateTime(a.Date) == todaysDate.Date
                                                select a).DefaultIfEmpty().First();

                        if (attendanceNumber != null)
                        {
                            textBoxNumber.Text = attendanceNumber.Number.ToString();
                        }
                        else
                        {
                            textBoxNumber.Text = "0";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
        public bool AddFormToList(Form addForm, int type, string fileName)
        {
            try
            {
                var formCheckExists = (from f in formsList
                                       where f.name == fileName
                                       select f).DefaultIfEmpty().First();

                if (formCheckExists == null)
                {
                    FormsToDisplay formToAdd = new FormsToDisplay();
                    formToAdd.type = type;
                    formToAdd.name = fileName;
                    formToAdd.form = addForm;

                    formsList.Add(formToAdd);

                    RefreshTable();

                    return(true);
                }
                else
                {
                    MessageBox.Show("File is already open");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
                return(false);
            }
        }
Exemple #10
0
        private void InitializeLabels()
        {
            try
            {
                this.labelsTableAdapter.Fill(this.lorikeetAppDataSet.Labels);

                DataTable labels = this.lorikeetAppDataSet.Labels;

                if (labels.Rows.Count == 0)
                {
                    return;
                }

                schedulerControl1.Storage.Appointments.Labels.Clear();

                schedulerControl1.Storage.Appointments.Labels.BeginUpdate();
                for (int i = 0; i < labels.Rows.Count; i++)
                {
                    Color            color       = Color.FromArgb(Int32.Parse(labels.Rows[i].ItemArray[1].ToString()));
                    string           displayName = labels.Rows[i].ItemArray[2].ToString();
                    string           menuCaption = labels.Rows[i].ItemArray[3].ToString();
                    AppointmentLabel aptLabel    = schedulerControl1.Storage.Appointments.Labels.CreateNewLabel(labels.Rows[i].ItemArray[0], displayName, menuCaption, color);
                    schedulerControl1.Storage.Appointments.Labels.Add(aptLabel);
                }

                schedulerControl1.Storage.Appointments.Labels.EndUpdate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
        private void GetActivityNumbers()
        {
            try
            {
                DateTime todaysDate;

                if (DateTime.TryParse(dateEditEditActivity.Text, out todaysDate))
                {
                    using (var context = new LorikeetAppEntities())
                    {
                        var activityNumber = (from a in context.AppointmentsNumbers
                                              join l in context.Labels on a.LabelID equals l.LabelID
                                              where DbFunctions.TruncateTime(a.Date) == todaysDate.Date && l.DisplayName == comboBoxEditLabels.Text
                                              select a).DefaultIfEmpty().First();

                        if (activityNumber != null)
                        {
                            textBoxNumber.Text = activityNumber.Number.ToString();
                        }
                        else
                        {
                            textBoxNumber.Text = "0";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }
Exemple #12
0
        private void MainMap_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                try
                {
                    isMouseDown = false;

                    var request = new GeocodingRequest
                    {
                        Key = MiscStuff.googleApiKey,
                        Location = new GoogleApi.Entities.Common.Location(currentMarker.Position.Lat, currentMarker.Position.Lng)
                    };
                    var response = GoogleMaps.Geocode.Query(request);

                    if (response.Status == Status.Ok)
                    {
                        textBoxAddress.Text = response.Results.First().FormattedAddress;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(MiscStuff.GetAllMessages(ex));
                }
            }
        }
        private bool checkIfAppointmentExists(string appointmentName, DateTime date)
        {
            try
            {
                using (var context = new LorikeetAppEntities())
                {
                    var checkIfAppointmentExists = (from app in context.Appointments
                                                    where app.Subject == appointmentName && DbFunctions.TruncateTime(app.StartDate) == DbFunctions.TruncateTime(date)
                                                    select app).FirstOrDefault();

                    if (checkIfAppointmentExists == null)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
            return(false);
        }
        private void UpdateLabelsList()
        {
            try
            {
                using (var context = new LorikeetAppEntities())
                {
                    var labelsToAddToList = (from l in context.Labels
                                             select l).ToList();

                    if (labelsToAddToList.Any())
                    {
                        foreach (var labels in labelsToAddToList)
                        {
                            comboBoxEditLabels.Properties.Items.Add(labels.DisplayName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }

            comboBoxEditLabels.SelectedIndex = 0;
        }
Exemple #15
0
 public static int GetAccessLevel(int staffID)
 {
     try
     {
         using (var context = new LorikeetAppEntities())
         {
             var accessLevel = (from l in context.Logins
                                join s in context.Staffs on l.LoginID equals s.LoginID
                                where s.StaffID == staffID
                                select l.Access).FirstOrDefault();
             if (accessLevel != null)
             {
                 return(accessLevel.Value);
             }
             else
             {
                 return(-1);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
     return(0);
 }
        public FormAddEditLogin(int staffID)
        {
            InitializeComponent();

            this.staffID = staffID;
            access       = MiscStuff.GetAccessLevel(staffID);
        }
Exemple #17
0
        private void FixMistake()
        {
            DialogResult dr = new DialogResult();

            if (debitIDSelected != -1)
            {
                FormInput form = null;

                if (debitSel)
                {
                    form = new FormInput("Enter Debit Amount to Change", "OK", true);
                    dr   = form.ShowDialog();
                }
                else
                {
                    form = new FormInput("Enter Credit Amount to Change", "OK", true);
                    dr   = form.ShowDialog();
                }

                if (dr == DialogResult.OK)
                {
                    try
                    {
                        using (var context = new LorikeetAppEntities())
                        {
                            var debitcreditToUpdate = (from d in context.DebitSystems
                                                       where d.DebitID == debitIDSelected
                                                       select d).FirstOrDefault();

                            if (debitcreditToUpdate != null)
                            {
                                decimal debitCredit;
                                if (decimal.TryParse(form.inputText, out debitCredit))
                                {
                                    if (debitSel)
                                    {
                                        debitcreditToUpdate.Debit  = debitCredit;
                                        debitcreditToUpdate.Credit = 0;
                                    }
                                    else
                                    {
                                        debitcreditToUpdate.Credit = debitCredit;
                                        debitcreditToUpdate.Debit  = 0;
                                    }
                                    context.SaveChanges();
                                    UpdateRunningTotal();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(MiscStuff.GetAllMessages(ex));
                    }
                    this.debitSystemTableAdapter.FillByMemberID(this.lorikeetAppDataSet.DebitSystem, memberID);
                }
            }
        }
        private void AddActivity(DevExpress.Spreadsheet.Cell cellTempActivity)
        {
            try
            {
                if (!cellTempActivity.Value.IsEmpty)
                {
                    DateTime date;
                    String[] splitCellActivity   = cellTempActivity.Value.ToString().Split(new char[] { '-', '=' });
                    string   strActivity         = "";
                    string   strActivityShortcut = "";
                    if (!DateTime.TryParseExact(cellTempActivity.Value.ToString(), "MMMM", new CultureInfo("en-US"), DateTimeStyles.None, out date))
                    {
                        if (splitCellActivity.Count() == 1)
                        {
                            splitCellActivity   = cellTempActivity.Value.ToString().Split(' ');
                            strActivityShortcut = splitCellActivity.Last().Trim();
                            strActivity         = cellTempActivity.Value.ToString().Replace(cellTempActivity.Value.ToString(), "").Trim();
                        }
                        else
                        {
                            strActivityShortcut = splitCellActivity[1].Trim();
                            strActivity         = splitCellActivity[0].Trim();
                        }
                        if (strActivity.Equals("") || strActivityShortcut.Equals(""))
                        {
                        }
                        else
                        {
                            using (var context = new LorikeetAppEntities())
                            {
                                var checkIfActivityExists = (from l in context.Labels
                                                             where l.Shortcut == strActivityShortcut
                                                             select l).DefaultIfEmpty().First();

                                if (checkIfActivityExists == null)
                                {
                                    var activityLabel = new Lorikeet.Data.Label();
                                    activityLabel.DisplayName = strActivity;
                                    activityLabel.MenuCaption = strActivity;
                                    activityLabel.Shortcut    = strActivityShortcut;
                                    Random r           = new Random(DateTime.Now.Millisecond);
                                    Color  randomColor = Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255));
                                    activityLabel.Color = randomColor.ToArgb();

                                    context.Labels.Add(activityLabel);
                                    context.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
                return;
            }
        }
        private string addActivity(string activityShortcut, ref Cell cellToEdit)
        {
            try
            {
                var          formGetInput = new FormAddActivity(activityShortcut);
                DialogResult dr           = new DialogResult();

                dr = formGetInput.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    using (var context = new LorikeetAppEntities())
                    {
                        var activityLabel = new Lorikeet.Data.Label
                        {
                            DisplayName = formGetInput.activity,
                            MenuCaption = formGetInput.activity,
                            Shortcut    = activityShortcut
                        };
                        Random r           = new Random(DateTime.Now.Millisecond);
                        Color  randomColor = Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255));
                        activityLabel.Color = randomColor.ToArgb();

                        context.Labels.Add(activityLabel);
                        context.SaveChanges();
                    }
                    return(formGetInput.activity);
                }
                else
                {
                    string cellString = cellToEdit.Value.ToString();
                    cellString.Replace(activityShortcut, formGetInput.shortcut);
                    cellToEdit.SetValueFromText(formGetInput.shortcut);
                    using (var context = new LorikeetAppEntities())
                    {
                        var getActivityLabel = (from l in context.Labels
                                                where l.Shortcut == activityShortcut
                                                select l).FirstOrDefault();

                        if (getActivityLabel != null)
                        {
                            return(getActivityLabel.DisplayName);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
                DialogResult = DialogResult.Abort;
                return(null);
            }
        }
 private void gridView1_Click(object sender, EventArgs e)
 {
     try
     {
         rowSelected = (int)gridView1.GetFocusedRowCellValue("LabelID");
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
 private void FormEditActivities_Load(object sender, EventArgs e)
 {
     try
     {
         this.labelsTableAdapter.Fill(this.lorikeetAppDataSet.Labels);
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
Exemple #22
0
 private void RefreshNotesGrid()
 {
     try
     {
         this.noteTableAdapter.FillByMemberID(this.lorikeetAppDataSet.Note, memberID);
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
Exemple #23
0
 private void buttonCenter_Click(object sender, EventArgs e)
 {
     try
     {
         CenterOnPosition(textBoxAddress.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
Exemple #24
0
 private void navBarItemCOOReport_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
 {
     try
     {
         var report = new FormReportCountryOfOriginsReport();
         report.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
 private void gridView1_RowUpdated_1(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
 {
     try
     {
         labelsTableAdapter.Update(lorikeetAppDataSet);
         lorikeetAppDataSet.AcceptChanges();
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
Exemple #26
0
        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            var view = (GridView)sender;

            GridHitInfo hitInfo = view.CalcHitInfo(view.GridControl.PointToClient(MousePosition));

            if (hitInfo.HitTest == GridHitTest.RowCell)
            {
                debitIDSelected = int.Parse(view.GetRowCellDisplayText(hitInfo.RowHandle, colDebitID).ToString());
                rowSelected     = view.GetSelectedRows()[0];
            }

            var columnName = view.FocusedColumn;

            if (columnName.GetCaption().Equals("Details"))
            {
                DialogResult dr   = new DialogResult();
                var          form = new FormInput("Enter in the Details", "OK");
                dr = form.ShowDialog();

                try
                {
                    using (var context = new LorikeetAppEntities())
                    {
                        if (dr == DialogResult.OK)
                        {
                            var debitCreditChangeText = (from d in context.DebitSystems
                                                         where d.DebitID == debitIDSelected
                                                         select d).FirstOrDefault();

                            if (debitCreditChangeText != null)
                            {
                                debitCreditChangeText.Details = form.inputText;
                                context.SaveChanges();
                            }
                            this.debitSystemTableAdapter.FillByMemberID(this.lorikeetAppDataSet.DebitSystem, memberID);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(MiscStuff.GetAllMessages(ex));
                }
                fixable = false;
                bbiFixMistake.Enabled = false;
                debitSel = false;
            }
            else if (columnName.GetCaption().Equals("Debit") || columnName.GetCaption().Equals("Credit"))
            {
                FixMistake();
            }
        }
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         labelsTableAdapter.InsertQuery(0, "Change Me", "Change Me", "CM");
         lorikeetAppDataSet.AcceptChanges();
         labelsTableAdapter.Fill(lorikeetAppDataSet.Labels);
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
Exemple #28
0
 private void navBarItemDebtors_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
 {
     try
     {
         var report = new XtraReports.XtraReportDebtors();
         report.CreateDocument();
         documentViewer1.DocumentSource = report;
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
Exemple #29
0
 private void schedulerControl1_EditAppointmentFormShowing_1(object sender, AppointmentFormEventArgs e)
 {
     try
     {
         DevExpress.XtraScheduler.SchedulerControl scheduler = ((DevExpress.XtraScheduler.SchedulerControl)(sender));
         var form = new OutlookAppointmentForm(scheduler, e.Appointment, e.OpenRecurrenceForm);
         e.DialogResult = form.ShowDialog();
         e.Handled      = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(MiscStuff.GetAllMessages(ex));
     }
 }
Exemple #30
0
        public static void AddLogEntry(int staffID, ErrorCodes errorCode, RefreshCodes refreshCode, string message, bool displayNotifyIcon)
        {
            try
            {
                if (displayNotifyIcon)
                {
                    NotifyIcon notifyIcon1 = new NotifyIcon();

                    if (errorCode == ErrorCodes.None)
                    {
                        notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.None;
                    }
                    else if (errorCode == ErrorCodes.OK)
                    {
                        notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;
                    }
                    else if (errorCode == ErrorCodes.Warning)
                    {
                        notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Warning;
                    }
                    else if (errorCode == ErrorCodes.Error)
                    {
                        notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Error;
                    }

                    notifyIcon1.BalloonTipText  = message;
                    notifyIcon1.BalloonTipTitle = "Logging";
                    notifyIcon1.Visible         = true;
                    notifyIcon1.ShowBalloonTip(3000);
                }


                using (var context = new LorikeetAppEntities())
                {
                    var logToAdd = new Log();
                    logToAdd.DateTime    = DateTime.Now;
                    logToAdd.ErrorCode   = (int)errorCode;
                    logToAdd.Message     = message;
                    logToAdd.StaffID     = staffID;
                    logToAdd.RefreshCode = (int)refreshCode;

                    context.Logs.Add(logToAdd);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MiscStuff.GetAllMessages(ex));
            }
        }