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); }
/// <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); } } }
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"); } } }
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); } }
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); }
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 }); } }
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); }
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(); } }
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); } }
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"); } }
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; } } }
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; } }
private void rbFilterYear_Checked(object sender, RoutedEventArgs e) { var query = HandleItems.GetTripsFiltered(-12); FillListData(query); }
private void btnGetOwnReports_Click(object sender, RoutedEventArgs e) { FillListData(HandleItems.GetTrips()); }
public async Task MarkItemAsDamaged(int id, int count) { HandleItems items = new HandleItems(); items.MarkItemAsDamaged(id, count); }
public Settings() { InitializeComponent(); FillUserInformation(); HandleItems.FillUserList(cbUser); }
public async Task RemoveItem(int id) { HandleItems items = new HandleItems(); items.RemoveItem(id); }
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(); }
public async Task <Item> GetItem(int id) { HandleItems items = new HandleItems(); return(items.GetItem(id)); }
/// <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); }
public async Task EditItem(Item item) { HandleItems items = new HandleItems(); items.EditItem(item); }
internal static void OnHandleItems() { HandleItems?.Invoke(); HandleItems = null; }