@@ -36,6 +36,7 @@ public partial class RapportHantering : Window
{
public List<FullTrip> fulltrips;
public Dictionary<string, Vacation> dic;
public bool bossFound;
public RapportHantering()
{
InitializeComponent();
@@ -44,8 +45,27 @@ public RapportHantering()
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;
@@ -64,7 +84,8 @@ private void ClearFieldsAndReloadBoxes()
lbReportsDenied.Items.Clear();
HandleItems.FillListBoxWithAwaitingApproval(lbReportsDenied);
HandleItems.FillCbsWithCountries(cbCountryArrival, cbCountryDeparture);

LoadReseUtlägg();
//HandleItems.FillTripCbWithAllTrips(cbPickTripExpensesTab);
}


@@ -94,7 +115,8 @@ private void btnSend_Click(object sender, RoutedEventArgs e)
int.TryParse(prepay, out prepaySum);
realtrip.prepayment = prepaySum;
realtrip.note = tbMotivation.Text;
realtrip.user = (int)cbBosses.SelectedItem;
realtrip.boss = (int)cbBosses.SelectedItem;
realtrip.user = HandleItems.GetCurrentUserId();
//validerar informationen som hämtats ut or boxarna
if (Validering.CheckPrepaySum((int)realtrip.prepayment))
{
@@ -117,6 +139,7 @@ private void btnSend_Click(object sender, RoutedEventArgs e)
ClearFieldsAndReloadBoxes();



}
}

@@ -128,11 +151,12 @@ private void btnAddVerification_Click(object sender, RoutedEventArgs e)
var verification = new VerificationModel();
verification.cost = price;
verification.note = tbCostNotes.Text;
verification.date = dpExpence.DisplayDate;
fulltrips[cbPickTripExpensesTab.SelectedIndex].myVerifications.Add(verification);

Serializer.Overwrite(fulltrips);
//List<FullTrip> test = new List<FullTrip>();
//test = (List<FullTrip>)cbPickTripExpensesTab.ItemsSource;
MessageBox.Show("Kostnad tillagd till resan.");
}


@@ -241,45 +265,62 @@ private void CheckBox_Checked(object sender, RoutedEventArgs e)

private void btnShowOwnReports_Click(object sender, RoutedEventArgs e)
{
var row = lvReports.SelectedItem.ToString();
string[] col = row.Split(',');

string id = Regex.Match(col[0], @"\d+").Value;
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);


PdfDocument pdf = new PdfDocument();
pdf.Info.Title = name;
PdfPage pdfPage = pdf.AddPage();
XGraphics graph = XGraphics.FromPdfPage(pdfPage);
XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
XFont minifont = new XFont("Verdana", 15);

XImage img = XImage.FromFile("C:\\Users\\Peter\\Documents\\GitHub\\ResehanteringsSystem\\vITs\\vITs\\Graphics\\pdfImage.gif");
graph.DrawImage(img, 10, 10, 80, 80);
graph.DrawString("Anställd: " + name, font, XBrushes.Black, new XRect(0, -330, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Id: " + id, minifont, XBrushes.Black, new XRect(0, -285, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Destination: " + destination, minifont, XBrushes.Black, new XRect(0, -265, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Datum: " + date, minifont, XBrushes.Black, new XRect(0, -245, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Status :" + state, minifont, XBrushes.Black, new XRect(0, -225, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
string pdfFilename = id + ".pdf";
if (pdfFilename != "")
if (lvReports.SelectedItem != null)
{
pdf.Save(pdfFilename);
var row = lvReports.SelectedItem.ToString();
string[] col = row.Split(',');

string id = Regex.Match(col[0], @"\d+").Value;
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);

var verifications = VerificationRepository.GetVerifications(Convert.ToInt32(id));

PdfDocument pdf = new PdfDocument();
pdf.Info.Title = name;
PdfPage pdfPage = pdf.AddPage();
XGraphics graph = XGraphics.FromPdfPage(pdfPage);
XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
XFont minifont = new XFont("Verdana", 15);
var y = -160;
/*XImage img =
XImage.FromFile(
"C:\\Users\\Peter\\Documents\\GitHub\\ResehanteringsSystem\\vITs\\vITs\\Graphics\\pdfImage.gif");*/
//graph.DrawImage(img, 10, 10, 80, 80);
graph.DrawString("Anställd: " + name, font, XBrushes.Black, new XRect(0, -330, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Id: " + id, minifont, XBrushes.Black, new XRect(0, -285, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Destination: " + destination, minifont, XBrushes.Black,
new XRect(0, -265, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Datum: " + date, minifont, XBrushes.Black, new XRect(0, -245, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Status :" + state, minifont, XBrushes.Black, new XRect(0, -225, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
graph.DrawString("Utgifter", font, XBrushes.Black, new XRect(0, -180, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
foreach (var v in verifications)
{

graph.DrawString(ExpencesRepository.GetExpence(v.expenceID) + ", Kostnad: "+v.cost+", Note: " + v.note, minifont, XBrushes.Black, new XRect(0, y, pdfPage.Width.Point,
pdfPage.Height.Point), XStringFormat.Center);
y -= 20;
}

string pdfFilename = id + ".pdf";
if (pdfFilename != "")
{
pdf.Save(pdfFilename);
}
Process.Start(pdfFilename);
}
Process.Start(pdfFilename);
}

private void btnGetOwnReports_Click(object sender, RoutedEventArgs e)
@@ -304,7 +345,11 @@ public void FillListData(IEnumerable<Object> query)
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 ((int) state == 2)
if (state == null)
{
state = "Offline";
}
if ((int)state == 2)
{
state = "EJ OK";
}
@@ -319,6 +364,18 @@ public void FillListData(IEnumerable<Object> query)

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
});
}
}


@@ -348,7 +405,27 @@ private void rbFilterYear_Checked(object sender, RoutedEventArgs e)

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;
}
}
}

private void sendMail(bool accepted, int id)
BIN +512 Bytes (100%) vITs/vITs/bin/Debug/DAL.exe
Binary file not shown.
BIN +10 KB (120%) vITs/vITs/bin/Debug/DAL.pdb
Binary file not shown.
BIN +0 Bytes (100%) vITs/vITs/bin/Debug/Database.mdf
Binary file not shown.
Binary file not shown.
BIN +3 KB (100%) vITs/vITs/bin/Debug/vITs.exe
Binary file not shown.
BIN +4 KB (100%) vITs/vITs/bin/Debug/vITs.pdb
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.
BIN +3 KB (100%) vITs/vITs/obj/Debug/vITs.exe
Binary file not shown.
BIN +190 Bytes (100%) vITs/vITs/obj/Debug/vITs.g.resources
Binary file not shown.
BIN +4 KB (100%) vITs/vITs/obj/Debug/vITs.pdb
Binary file not shown.
@@ -204,6 +204,7 @@
<DependentUpon>Database.mdf</DependentUpon>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Graphics\pdfImage.gif" />
<Resource Include="Graphics\bg_border.png" />
<Resource Include="Graphics\bg.png" />
<Resource Include="Graphics\btn.png" />