96 lines
3.4 KiB
C#
96 lines
3.4 KiB
C#
using BrightIdeasSoftware;
|
|
using Npgsql;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DatenDB
|
|
{
|
|
public class OLVKundenumsatz
|
|
{
|
|
private static List<OLVKundenumsatz> resultlist;
|
|
public OLVKundenumsatz()
|
|
{
|
|
}
|
|
|
|
[OLVColumn(DisplayIndex = 0, TextAlign = System.Windows.Forms.HorizontalAlignment.Center)]
|
|
public string Zeitraum { get; set; }
|
|
|
|
//[OLVColumn(DisplayIndex = 1, TextAlign = System.Windows.Forms.HorizontalAlignment.Center)]
|
|
//public double Jahr { get; set; }
|
|
|
|
[OLVColumn(DisplayIndex = 2, TextAlign = System.Windows.Forms.HorizontalAlignment.Right, AspectToStringFormat = "{0:C}")]
|
|
public double Umsatz { get; set; }
|
|
|
|
//[OLVColumn(DisplayIndex = 3, TextAlign = System.Windows.Forms.HorizontalAlignment.Right, AspectToStringFormat = "{0:C}")]
|
|
//public double DifferenzEUR { get; set; }
|
|
|
|
//[OLVColumn(DisplayIndex = 4, TextAlign = System.Windows.Forms.HorizontalAlignment.Center, AspectToStringFormat = "{0:P1}")]
|
|
//public double DifferenzPro { get; set; }
|
|
|
|
public static List<OLVKundenumsatz> GetJahresumsatz(int? kndid)
|
|
{
|
|
resultlist = new List<OLVKundenumsatz>();
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
command.CommandText = $"select jahr, umsatz from kundenverwaltung.jahresumsaetze where kunde_id = {kndid} order by jahr";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) resultlist.Add(new OLVKundenumsatz(reader, true));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
return resultlist;
|
|
}
|
|
|
|
public static List<OLVKundenumsatz> GetMonatsumsatz(int? kndid)
|
|
{
|
|
resultlist = new List<OLVKundenumsatz>();
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
command.CommandText = $"select monat, umsatz1, jahr from kundenverwaltung.monatsumsaetze where kunde_id = {kndid} order by jahr, monat";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) resultlist.Add(new OLVKundenumsatz(reader, false));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
|
|
return resultlist;
|
|
}
|
|
|
|
public static List<OLVKundenumsatz> GetQuartalsumsatz(int? kndid)
|
|
{
|
|
resultlist = new List<OLVKundenumsatz>();
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
command.CommandText = $"select quartal, umsatz, jahr from kundenverwaltung.q_umsatz where kunde_id = {kndid} order by jahr, quartal";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) resultlist.Add(new OLVKundenumsatz(reader, false));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
return resultlist;
|
|
}
|
|
|
|
public OLVKundenumsatz(NpgsqlDataReader reader, bool jahr)
|
|
{
|
|
if (jahr)
|
|
{
|
|
this.Zeitraum = reader.GetDouble(0).ToString();
|
|
this.Umsatz = reader.GetDouble(1);
|
|
}
|
|
else
|
|
{
|
|
this.Zeitraum = reader.GetDouble(0).ToString() + "." + reader.GetDouble(2).ToString();
|
|
this.Umsatz = reader.GetDouble(1);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|