private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            var userID = cbUser.SelectedItem.ToString().Split('.')[0];

            AddUser.DeleteUser(Convert.ToInt16(userID), cbUser);
            HandleItems.FillUserList(cbUser);
        }
示例#2
0
        /// <summary>
        /// Receive items into the warehouse.
        /// </summary>
        /// <param name="id">id of item to receive</param>
        /// <param name="count">Count of item to receive</param>
        /// <returns>Nothing.</returns>
        public async Task ReceiveItem(int id, int count)
        {
            System.Diagnostics.Debug.WriteLine("ClientWebServiceConfirm");
            HandleItems items = new HandleItems();

            items.ReturnItems(id, count);
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            UserModel userModel = new UserModel(tbxFirstName.Text, tbxLastName.Text,
                                                tbxPasswordFirst.Password, tbxEmail.Text, tbxTele.Text);

            if (AddUser.ValidateAddUser(tbxFirstName, tbxLastName,
                                        tbxPasswordFirst, tbxPasswordSecond, tbxEmail, tbxTele))
            {
                if (cbxBoss.IsChecked == true)
                {
                    AddUser.AddBoss(userModel);
                    AddUser.ClearText(tbxFirstName, tbxLastName,
                                      tbxPasswordFirst, tbxPasswordSecond, tbxEmail, tbxTele, cbxBoss);
                    cbUser.Items.Clear();
                    HandleItems.FillUserList(cbUser);
                }
                else
                {
                    AddUser.AddNewUser(userModel);
                    AddUser.ClearText(tbxFirstName, tbxLastName,
                                      tbxPasswordFirst, tbxPasswordSecond, tbxEmail, tbxTele, cbxBoss);
                    cbUser.Items.Clear();
                    HandleItems.FillUserList(cbUser);
                }
            }
        }
示例#4
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            var userinput     = tbxUser.Text;
            var passwordinput = pbxPassword.Password;

            if (userinput.Trim() == "" || passwordinput.Trim() == "")
            {
                MessageBox.Show("Fyll i alla fälten");
            }
            else
            {
                int value;
                if (int.TryParse(userinput, out value))
                {
                    var user = HandleItems.GetUser(value);
                    if (user.userID.Equals(value) && user.password.Equals(passwordinput))
                    {
                        Application.Current.Properties["currentUser"] = user;
                        Application.Current.Properties["currentUser"] = UserHandling.GetUser(value);
                        var rapport = new RapportHantering();
                        rapport.Show();
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Inlogg eller lösenord fel");
                    }
                }
                else
                {
                    MessageBox.Show("Fyll i alla fälten");
                }
            }
        }
示例#5
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            HandleItems h = new HandleItems(checkedListBox1);

            foreach (var item in checkedListBox1.CheckedItems.OfType <Item1>().ToList())
            {
                h.RemoveItem(item, list1);
                System.IO.File.Delete(folder_path + @"\" + item.Name_ + file_extention);
            }
        }
示例#6
0
 private void ClearFieldsAndReloadBoxes()
 {
     tbPrepaySum.Clear();
     tbMotivation.Clear();
     cbCountryDeparture.Items.Clear();
     cbCountryArrival.Items.Clear();
     lbReportsDenied.Items.Clear();
     HandleItems.FillListBoxWithAwaitingApproval(lbReportsDenied);
     HandleItems.FillCbsWithCountries(cbCountryArrival, cbCountryDeparture);
     LoadReseUtlägg();
     //HandleItems.FillTripCbWithAllTrips(cbPickTripExpensesTab);
 }
示例#7
0
        public void FillListData(IEnumerable <Object> query)
        {
            if (lvReports.Items.Count >= 1)
            {
                lvReports.Items.Clear();
            }
            var queryTrips = HandleItems.GetTrips();

            foreach (var item in queryTrips)
            {
                //Type type = item.GetType();
                //var properties = type.GetProperties();

                var id          = item.GetType().GetProperty("id").GetValue(item).ToString();
                var consultant  = item.GetType().GetProperty("consultant").GetValue(item).ToString();
                var destination = item.GetType().GetProperty("destination").GetValue(item).ToString();
                var date        = item.GetType().GetProperty("date").GetValue(item).ToString();
                var state       = item.GetType().GetProperty("status").GetValue(item);
                if (state == null)
                {
                    state = "Offline";
                }
                if ((int)state == 2)
                {
                    state = "EJ OK";
                }
                else if ((int)state == 1)
                {
                    state = "OK";
                }
                else
                {
                    state = "Väntar";
                }

                lvReports.Items.Add(new { id, consultant, destination, date, status = state });
            }
            var serializedTrips = Serializer.Load();

            foreach (var item in serializedTrips)
            {
                lvReports.Items.Add(new
                {
                    id          = item.myTrip.TripId,
                    consultant  = item.myTrip.User,
                    destination = item.myTrip.Destination,
                    date        = item.myTrip.Start,
                    status      = item.myTrip.Status
                });
            }
        }
示例#8
0
        public Form1()
        {
            InitializeComponent();
            HandleItems h = new HandleItems(checkedListBox1);

            Directory.CreateDirectory(folder_path);
            var x = h.Deserialize(list1);

            if (x != null)
            {
                list1 = x;
            }
            Application.ApplicationExit += new EventHandler(this.OnApplicationExit);
        }
示例#9
0
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            var realtrip = new Trip();


            var trip = new TripModel();

            //fyller modellen med information

            realtrip.origin      = (int)cbCountryDeparture.SelectedValue;
            realtrip.destination = (int)cbCountryArrival.SelectedValue;
            realtrip.start       = (DateTime)dpStartDate.SelectedDate;
            realtrip.end         = (DateTime)dpEndDate.SelectedDate;
            var prepay = tbPrepaySum.Text;
            int prepaySum;

            int.TryParse(prepay, out prepaySum);
            realtrip.prepayment = prepaySum;
            realtrip.note       = tbMotivation.Text;
            realtrip.boss       = (int)cbBosses.SelectedItem;
            realtrip.user       = HandleItems.GetCurrentUserId();
            //validerar informationen som hämtats ut or boxarna
            if (Validering.CheckPrepaySum((int)realtrip.prepayment))
            {
                var FullTrip = new FullTrip();
                FullTrip.myTrip = ModelTransformer.Trip2TripModel(realtrip);
                foreach (Vacation item in lbVacations.Items)
                {
                    FullTrip.myVacation.Add(ModelTransformer.Vacation2VacationModel(item));
                }

                //              DB!!!
                //TripRepository.AddTrip(realtrip);
                //foreach(var item in FullTrip.myVacation)
                //{
                //    var vacation = ModelTransformer.VacationModel2Vacation(item);
                //    vacation.tripID = realtrip.tripID;
                //    VacationsRepository.AddVacation(vacation);
                //}
                Serializer.Save(FullTrip);
                ClearFieldsAndReloadBoxes();
            }
        }
示例#10
0
        private void sendMail(bool accepted, int id)
        {
            String mail = HandleItems.GetUser(id).email;
            String name = HandleItems.GetUser(id).firstname.ToString() + " " + HandleItems.GetUser(id).lastname.ToString();

            var    fromAddress  = new MailAddress("*****@*****.**", "vITS");
            string fromPassword = "******";

            var toAddress = new MailAddress(mail, name);

            String acceptedText = "";

            if (accepted == true)
            {
                acceptedText = "accepterad.";
            }
            else
            {
                acceptedText = "nekad.";
            }

            string subject = "Angående rapport";
            string body    = "Din rapport är nu " + acceptedText + "\n" + DateTime.Now.ToString("M/d/yyyy");

            var smtp = new SmtpClient
            {
                Host           = "smtp.gmail.com",
                Port           = 587,
                EnableSsl      = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                Timeout        = 15000
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }
        }
示例#11
0
        private void button1_Click(object sender, EventArgs e)
        {
            HandleItems h    = new HandleItems(checkedListBox1);
            Item1       item = new Item1(textBox1.Text, dateTimePicker1.Value.Date);

            if (textBox1.Text != "")
            {
                int x = 0;
                foreach (Item1 value in list1)
                {
                    if (item.Name_ == value.Name_)
                    {
                        MessageBox.Show("There is already an item with the same name", "Error");
                        x = 1;
                    }
                }
                if (x == 0)
                {
                    if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        var fileName = string.Empty;
                        var savePath = string.Empty;
                        fileName = openFileDialog1.SafeFileName;
                        savePath = (folder_path + @"\" + textBox1.Text + ".pdf");
                        var file = openFileDialog1.FileName;
                        System.IO.File.Copy(file, savePath);
                        MessageBox.Show("File selected: " + fileName, "File has been added", MessageBoxButtons.OK);

                        h.AddItem(item, list1);
                        textBox1.Clear();
                    }
                    else
                    {
                        MessageBox.Show("No file selected!", "Warning!", MessageBoxButtons.OK);
                    }
                }
            }
            else
            {
                MessageBox.Show("Name can't be empty", "Error");
            }
        }
示例#12
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (lvReports.SelectedItem != null)
            {
                var      row = lvReports.SelectedItem.ToString();
                string[] col = row.Split(',');

                string id = Regex.Match(col[0], @"\d+").Value;
                if (Convert.ToInt32(id) == 0)
                {
                    string[] nameSplit        = col[1].Split('=');
                    string   name             = nameSplit[1].Trim();
                    string[] destinationSplit = col[2].Split('=');
                    string   destination      = destinationSplit[1].Trim();
                    string[] dateSplit        = col[3].Split('=');
                    string   date             = dateSplit[1].Trim();
                    string[] stateSplit       = col[4].Split('=');
                    string   state            = stateSplit[1].Trim().Substring(0, stateSplit[1].Length - 2);

                    HandleItems.SendRapport(Convert.ToInt32(name), Convert.ToInt32(destination), Convert.ToDateTime(date));
                    rbFilterAll.IsChecked = true;
                }
            }
        }
示例#13
0
        public RapportHantering()
        {
            InitializeComponent();
            HandleItems.FillBossList(cbBosses);
            LoadReseUtlägg();
            HandleItems.FillCbsWithCountries(cbCountryArrival, cbCountryDeparture);
            HandleItems.FillListBoxWithAwaitingApproval(lbReportsDenied);

            var bosses = UserHandling.getBosses();

            for (int i = 0; i < bosses.Count; i++)
            {
                if (bosses[i].userID == HandleItems.GetCurrentUserId())
                {
                    bossFound = true;
                }
            }
            if (bossFound == false)
            {
                tab3.Visibility = Visibility.Hidden;
                tab4.Visibility = Visibility.Hidden;
                tab5.Visibility = Visibility.Hidden;
            }

            if (HandleItems.GetCurrentUserId() == 0)
            {
                tab3.Visibility = Visibility.Hidden;
                tab4.Visibility = Visibility.Hidden;
                tab5.Visibility = Visibility.Hidden;
                tbSearchAnstIdDenied.IsEnabled   = false;
                btnGetReportsDenied.IsEnabled    = false;
                tbSearchAnstIdApproved.IsEnabled = false;
                btnGetReportsApproved.IsEnabled  = false;
                anvInstallningar.IsEnabled       = false;
            }
        }
示例#14
0
        private void rbFilterYear_Checked(object sender, RoutedEventArgs e)
        {
            var query = HandleItems.GetTripsFiltered(-12);

            FillListData(query);
        }
示例#15
0
 private void btnGetOwnReports_Click(object sender, RoutedEventArgs e)
 {
     FillListData(HandleItems.GetTrips());
 }
示例#16
0
        public async Task MarkItemAsDamaged(int id, int count)
        {
            HandleItems items = new HandleItems();

            items.MarkItemAsDamaged(id, count);
        }
 public Settings()
 {
     InitializeComponent();
     FillUserInformation();
     HandleItems.FillUserList(cbUser);
 }
示例#18
0
        public async Task RemoveItem(int id)
        {
            HandleItems items = new HandleItems();

            items.RemoveItem(id);
        }
示例#19
0
 private void OnApplicationExit(object sender, EventArgs e)
 {
     HandleItems.Serialize(list1);
 }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     AddUser.ChangePassword(HandleItems.GetCurrentUserId(), tbxNewPassword1, tbxNewPassword2, tbxOldPassword);
 }
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     AddUser.UpdateUser(HandleItems.GetCurrentUserId(), tbxUpdatePhone, tbxUpdateEmail);
     FillUserInformation();
 }
示例#22
0
        public async Task <Item> GetItem(int id)
        {
            HandleItems items = new HandleItems();

            return(items.GetItem(id));
        }
示例#23
0
        /// <summary>
        /// Adds a new item to database.
        /// </summary>
        /// <param name="item">Item to be added.</param>
        /// <returns>Nothing.</returns>
        public async Task AddNewItem(Item item)
        {
            HandleItems items = new HandleItems();

            items.AddNewItem(item);
        }
 public void FillUserInformation()
 {
     AddUser.FillUserInformation(HandleItems.GetCurrentUserId(), tbxUpdatePhone, tbxUpdateEmail);
 }
示例#25
0
        public async Task EditItem(Item item)
        {
            HandleItems items = new HandleItems();

            items.EditItem(item);
        }
示例#26
0
 internal static void OnHandleItems()
 {
     HandleItems?.Invoke();
     HandleItems = null;
 }