369 lines
15 KiB
C#
369 lines
15 KiB
C#
using Database;
|
|
using KlassenBIB;
|
|
using SanSystem.Einstellungen;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace SanSystem
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public partial class frmObjekteList : Form
|
|
{
|
|
|
|
private List<Inspektionsobjekt> inspektionsobjekte;
|
|
ObjecteListSetting objecteListSetting = new ObjecteListSetting();
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="streetname"></param>
|
|
private void loadObjekte(string streetname)
|
|
{
|
|
|
|
dGObjekte.DataSource = null;
|
|
inspektionsobjekte = Datenbank.Instance.loadedProjekt.Objekte.FindAll(x => x.StrasseName.Equals(streetname));
|
|
|
|
dGObjekte.DataSource = inspektionsobjekte;
|
|
}
|
|
|
|
private bool CheckEntries()
|
|
{
|
|
for(int i = 0; i < dGObjekte.Rows.Count; i++)
|
|
{
|
|
DataGridViewRow dgvw = dGObjekte.Rows[i];
|
|
Inspektionsobjekt tmp = (Inspektionsobjekt)dgvw.DataBoundItem;
|
|
if (tmp == null) continue;
|
|
dgvw.DefaultCellStyle.BackColor = Color.White;
|
|
|
|
int anzahlSan = tmp.Sanierung.Count;
|
|
int anzahlfertig = 0;
|
|
int counter = 0;
|
|
foreach(Sanierung san in tmp.Sanierung)
|
|
{
|
|
AbstractSanieren _san = (san as AbstractSanieren);
|
|
if (_san.Fertig) anzahlfertig++;
|
|
counter++;
|
|
}
|
|
if (!tmp.Haltungslaenge.Equals(0))
|
|
dgvw.DefaultCellStyle.BackColor = Color.Aquamarine;
|
|
if (counter != 0 && (anzahlfertig == anzahlSan))
|
|
dgvw.DefaultCellStyle.BackColor = Color.Green;
|
|
if (
|
|
(tmp.BisPunkt== null || tmp.BisPunkt.Equals(""))
|
|
|| (tmp.VonPunkt == null || tmp.VonPunkt.Equals(""))
|
|
|| (tmp.Objektbezeichnung == null || tmp.Objektbezeichnung.Equals(""))
|
|
|| tmp.Kanalrohrweite.Equals(0)
|
|
) dgvw.DefaultCellStyle.BackColor = Color.Olive;
|
|
if(tmp.Projektnummer == null || tmp.Projektnummer.Equals("")) dgvw.DefaultCellStyle.BackColor = Color.Red;
|
|
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="streetname"></param>
|
|
public frmObjekteList(string streetname)
|
|
{
|
|
InitializeComponent();
|
|
btn_set_kali.Enabled = false;
|
|
if (Global.Instance.AnlageType == CSVParser.AcceptedCSVFormats.UVRELINING)
|
|
{
|
|
DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
|
|
checkBoxColumn.Name = "Auswahl";
|
|
checkBoxColumn.HeaderText = "Auswahl";
|
|
//checkBoxColumn.Width = objecteListSetting.configuration["Auswahl"];
|
|
|
|
btn_set_kali.Enabled = true;
|
|
|
|
dGObjekte.Columns.Add(checkBoxColumn);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
label1.BackColor = Color.Red;
|
|
label5.BackColor = Color.Olive;
|
|
|
|
loadObjekte(streetname);
|
|
|
|
txt_strasse.Text = streetname;
|
|
|
|
string fehlermeldung = string.Empty;
|
|
// Prüfen nach Projektnummern
|
|
List<string> projektnummern = inspektionsobjekte.Select(x => x.Projektnummer).Distinct().ToList();
|
|
if (projektnummern.Count > 1) fehlermeldung = "Es sind mehrere Projektnummern in eine gleiche Straße vorhanden";
|
|
|
|
// Prüfen nach Ortnamen
|
|
List<string> ortnamen = inspektionsobjekte.Select(x => x.OrtName).Distinct().ToList();
|
|
if (ortnamen.Count > 1) fehlermeldung = string.Format("{0}\n\n{1}",fehlermeldung, "Es sind verschiedene Ortnamen angegeben");
|
|
|
|
if (!fehlermeldung.Equals(string.Empty)) MessageBox.Show(fehlermeldung, "Inhalt Fehler", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
if (projektnummern.Count > 1)
|
|
{
|
|
Dictionary<string, int> mayProNr = new Dictionary<string, int>();
|
|
List<int> anzahle = new List<int>();
|
|
foreach (string _prnr in projektnummern)
|
|
{
|
|
int anzahl = inspektionsobjekte.Where(x => x.Projektnummer.Equals(_prnr)).Count();
|
|
mayProNr.Add(_prnr, anzahl);
|
|
anzahle.Add(anzahl);
|
|
}
|
|
|
|
int max = anzahle.Max();
|
|
List<string> empProjNummer = new List<string>();
|
|
foreach (KeyValuePair<string, int> kvp in mayProNr)
|
|
{
|
|
if (kvp.Value.Equals(max)) empProjNummer.Add(kvp.Key);
|
|
else
|
|
continue;
|
|
}
|
|
if (empProjNummer.Count > 1) MessageBox.Show("Es konnte leider keine empfohlene Projektnummer emittelt werden!");
|
|
else
|
|
MessageBox.Show(string.Format("{0}\n{1}", "Der vermeintliche Projektnummer lautet: ", empProjNummer.Last()));
|
|
|
|
|
|
}
|
|
|
|
txt_ort.Text = ortnamen.First();
|
|
|
|
if (projektnummern.First() == null)
|
|
{
|
|
MessageBox.Show("Projektnummer wurde nicht korrekt vergeben!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
string[] vs = projektnummern.First().Split('-');
|
|
if (vs.Length > 0)
|
|
txt_pro_nr_1.Text = vs[0];
|
|
if (vs.Length > 1)
|
|
txt_pro_nr_2.Text = vs[1];
|
|
if (vs.Length > 2)
|
|
txt_pro_nr_3.Text = vs[2];
|
|
|
|
}
|
|
|
|
private void frmObjekteList_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void dGObjekte_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
|
|
{
|
|
|
|
DataGridView dataGridView = (DataGridView)sender;
|
|
if (dataGridView == null) return;
|
|
DataGridViewSelectedRowCollection dataGridViewRowsSelect = dataGridView.SelectedRows;
|
|
|
|
|
|
if (dataGridViewRowsSelect.Count > 1) return;
|
|
|
|
DataGridViewRow dgvr = dataGridViewRowsSelect[0];
|
|
|
|
Inspektionsobjekt inspektionsobjekt = (Inspektionsobjekt)dgvr.DataBoundItem;
|
|
if (inspektionsobjekt == null) return;
|
|
|
|
frmObjektEdit frmObjektEdit = new frmObjektEdit(inspektionsobjekt);
|
|
frmObjektEdit.FormClosed += FrmObjektEdit_FormClosed1;
|
|
frmObjektEdit.MdiParent = this.MdiParent;
|
|
frmObjektEdit.Show();
|
|
|
|
}
|
|
|
|
private void FrmObjektEdit_FormClosed1(object sender, FormClosedEventArgs e)
|
|
{
|
|
CheckEntries();
|
|
}
|
|
|
|
private void btn_add_Click(object sender, EventArgs e)
|
|
{
|
|
Inspektionsobjekt inspektionsobjekt = new Inspektionsobjekt();
|
|
//inspektionsobjekt.Guid = Guid.NewGuid();
|
|
inspektionsobjekt.Projektnummer = inspektionsobjekte.First().Projektnummer;
|
|
inspektionsobjekt.OrtName = inspektionsobjekte.First().OrtName;
|
|
inspektionsobjekt.StrasseName = inspektionsobjekte.First().StrasseName;
|
|
Datenbank.Instance.loadedProjekt.Objekte.Add(inspektionsobjekt);
|
|
|
|
frmObjektEdit frmObjektEdit = new frmObjektEdit(inspektionsobjekt,true);
|
|
frmObjektEdit.FormClosed += FrmObjektEdit_FormClosed;
|
|
frmObjektEdit.ShowDialog();
|
|
}
|
|
|
|
private void FrmObjektEdit_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
loadObjekte(txt_strasse.Text);
|
|
CheckEntries();
|
|
}
|
|
|
|
private void dGObjekte_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
|
|
{
|
|
CheckEntries();
|
|
dGObjekte.Columns["StrasseName"].Visible = false;
|
|
dGObjekte.Columns["OverrideAuftraggeber"].Visible = false;
|
|
dGObjekte.Columns["OrtName"].Visible = false;
|
|
dGObjekte.Columns["Projektnummer"].Visible = false;
|
|
dGObjekte.Columns["Rohrmaterial"].Visible = false;
|
|
dGObjekte.Columns["Kanalrohrweite"].Visible = false;
|
|
dGObjekte.Columns["Schachtlaenge"].Visible = false;
|
|
dGObjekte.Columns["Objektbezeichnung"].Visible = false;
|
|
dGObjekte.Columns["Haltunggemessen"].Visible = false;
|
|
dGObjekte.Columns["Bemerkung"].Visible = false;
|
|
dGObjekte.Columns["Guid"].Visible = false;
|
|
dGObjekte.Columns["Inspektionsrichtung"].Visible = false;
|
|
dGObjekte.Columns["GeschlossenesEnde"].Visible = false;
|
|
|
|
|
|
|
|
if(Global.Instance.AnlageType == CSVParser.AcceptedCSVFormats.UVRELINING)
|
|
dGObjekte.Columns["Auswahl"].Width = objecteListSetting.GetWidth(dGObjekte.Columns["Auswahl"]); // objecteListSetting.configuration["Auswahl"];
|
|
dGObjekte.Columns["Hausnummer"].Width = objecteListSetting.GetWidth(dGObjekte.Columns["Hausnummer"]);//objecteListSetting.configuration["Hausnummer"];
|
|
dGObjekte.Columns["VonPunkt"].Width = objecteListSetting.GetWidth(dGObjekte.Columns["VonPunkt"]);//objecteListSetting.configuration["VonPunkt"];
|
|
dGObjekte.Columns["BisPunkt"].Width = objecteListSetting.GetWidth(dGObjekte.Columns["BisPunkt"]);// objecteListSetting.configuration["BisPunkt"];
|
|
dGObjekte.Columns["Haltungslaenge"].Width = objecteListSetting.GetWidth(dGObjekte.Columns["Haltungslaenge"]); //objecteListSetting.configuration["Haltungslaenge"];
|
|
|
|
|
|
//dGObjekte.Columns["Sanierung"].Visible = false;
|
|
}
|
|
|
|
private void dGObjekte_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
CheckEntries();
|
|
}
|
|
|
|
private void frmObjekteList_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
objecteListSetting.SetWidth(dGObjekte.Columns["Hausnummer"]);
|
|
objecteListSetting.SetWidth(dGObjekte.Columns["VonPunkt"]);
|
|
objecteListSetting.SetWidth(dGObjekte.Columns["BisPunkt"]);
|
|
objecteListSetting.SetWidth(dGObjekte.Columns["Haltungslaenge"]);
|
|
objecteListSetting.SetWidth(dGObjekte.Columns["Auswahl"]);
|
|
|
|
objecteListSetting.SaveSettings();
|
|
|
|
}
|
|
|
|
private void btn_make_ausdruck_Click(object sender, EventArgs e)
|
|
{
|
|
return;
|
|
List<Inspektionsobjekt> ausdruck = new List<Inspektionsobjekt>();
|
|
|
|
DataGridViewCheckBoxCell checkBoxCell = null;
|
|
|
|
foreach(DataGridViewRow dr in dGObjekte.Rows)
|
|
{
|
|
checkBoxCell = (DataGridViewCheckBoxCell)dr.Cells["Auswahl"];
|
|
if (checkBoxCell == null) break;
|
|
if (checkBoxCell.Value == null) continue;
|
|
if ((bool)checkBoxCell.Value) ausdruck.Add((dr.DataBoundItem as Inspektionsobjekt));
|
|
}
|
|
|
|
if (ausdruck.Count <= 0) return;
|
|
|
|
Hashtable grundDaten = new Hashtable()
|
|
{
|
|
{"Ausdruck_datum","" },
|
|
{"Strasse","" },
|
|
{"Ort","" },
|
|
{"gesamt_liner","" },
|
|
{"harzmenge","" }
|
|
};
|
|
|
|
grundDaten["Ausdruck_datum"] = DateTime.Now.ToLongDateString();
|
|
|
|
grundDaten["Strasse"] = txt_strasse.Text;
|
|
grundDaten["Ort"] = txt_ort.Text;
|
|
|
|
DataTable linereintraege = getLinerTable();
|
|
double linerges = 0;
|
|
foreach(Inspektionsobjekt obj in ausdruck)
|
|
{
|
|
DataRow dr = linereintraege.NewRow();
|
|
double linergesamt = obj.Haltungslaenge + obj.Schachtlaenge;
|
|
dr["hausnummer"] = obj.Hausnummer;
|
|
dr["liner_laenge"] = obj.Haltungslaenge;
|
|
dr["schacht_laenge"] = obj.Schachtlaenge;
|
|
dr["liner_gesamt"] = linergesamt;
|
|
dr["san_nr"] = obj.Sanierungsnummer;
|
|
dr["dn"] = obj.Kanalrohrweite;
|
|
dr["bemerkung"] = obj.Bemerkung;
|
|
linerges += linergesamt;
|
|
linereintraege.Rows.Add(dr);
|
|
}
|
|
grundDaten["gesamt_liner"] = linerges;
|
|
grundDaten["harzmenge"] = linerges * 1.8;
|
|
BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("JUME", "KalibrierungAuflistung.docx", string.Format("{0}/KalibrierDokumente/",Global.Instance.Projektpfad),txt_strasse.Text, grundDaten, null, linereintraege);
|
|
options.ShowDialog();
|
|
}
|
|
|
|
private static DataTable getLinerTable()
|
|
{
|
|
DataTable dataTable = new DataTable("Liner");
|
|
DataColumn dataColumn = new DataColumn("hausnummer") { MaxLength = 80 };
|
|
dataTable.Columns.Add(dataColumn);
|
|
dataColumn = new DataColumn("san_nr") { MaxLength = 10 };
|
|
dataTable.Columns.Add(dataColumn);
|
|
dataColumn = new DataColumn("liner_laenge") { MaxLength = 50 };
|
|
dataTable.Columns.Add(dataColumn);
|
|
dataColumn = new DataColumn("schacht_laenge") { MaxLength = 50 };
|
|
dataTable.Columns.Add(dataColumn);
|
|
dataColumn = new DataColumn("liner_gesamt") { MaxLength = 50 };
|
|
dataTable.Columns.Add(dataColumn);
|
|
dataColumn = new DataColumn("dn") { MaxLength = 10 };
|
|
dataTable.Columns.Add(dataColumn);
|
|
dataColumn = new DataColumn("bemerkung") { MaxLength = 255 };
|
|
dataTable.Columns.Add(dataColumn);
|
|
return dataTable;
|
|
}
|
|
|
|
private void btn_set_kali_Click(object sender, EventArgs e)
|
|
{
|
|
List<Inspektionsobjekt> ausdruck = new List<Inspektionsobjekt>();
|
|
|
|
DataGridViewCheckBoxCell checkBoxCell = null;
|
|
|
|
foreach (DataGridViewRow dr in dGObjekte.Rows)
|
|
{
|
|
checkBoxCell = (DataGridViewCheckBoxCell)dr.Cells["Auswahl"];
|
|
if (checkBoxCell == null) break;
|
|
if (checkBoxCell.Value == null) continue;
|
|
if ((bool)checkBoxCell.Value)
|
|
{
|
|
Inspektionsobjekt objekt = (dr.DataBoundItem as Inspektionsobjekt);
|
|
bool bereitsVorhanden = false;
|
|
foreach(Sanierung san in objekt.Sanierung)
|
|
{
|
|
if(san is InlinerSanierung)
|
|
{
|
|
bereitsVorhanden = true;
|
|
break;
|
|
}
|
|
}
|
|
if(!bereitsVorhanden)
|
|
ausdruck.Add(objekt);
|
|
}
|
|
}
|
|
|
|
if (ausdruck.Count <= 0) return;
|
|
frmKalibrierungFestlegung frmKalibrierungFestlegung = new frmKalibrierungFestlegung(ausdruck);
|
|
frmKalibrierungFestlegung.ShowDialog();
|
|
}
|
|
|
|
private void btn_statistik_Click(object sender, EventArgs e)
|
|
{
|
|
frmSelectMassenDate frmSelectMassenDate = new frmSelectMassenDate(inspektionsobjekte);
|
|
frmSelectMassenDate.ShowDialog();
|
|
}
|
|
}
|
|
}
|