/// <summary> /// Kopykonstruktor. /// </summary> /// <param name="aMajitel"></param> public Majitel(Majitel aMajitel) { this.id = aMajitel.id; this.firstName = aMajitel.firstName; this.lastName = aMajitel.lastName; this.clen = aMajitel.clen; this.penize = aMajitel.penize; this.potvrzeni = aMajitel.potvrzeni; this.telefon = aMajitel.telefon; this.email = aMajitel.email; this.narodnost = aMajitel.narodnost; this.pocet_psu = aMajitel.pocet_psu; }
/// <summary> /// Ziska data o majiteli s danym ID, upravi je a zpet ulozi. /// </summary> /// <param name="id"></param> /// <param name="newData"></param> public void Edit(int id, Majitel newData) { Majitel oldData = this.GetMajitelById(id); oldData.firstName = newData.firstName; oldData.lastName = newData.lastName; oldData.clen = newData.clen; oldData.penize = newData.penize; oldData.potvrzeni = newData.potvrzeni; oldData.telefon = newData.telefon; oldData.email = newData.email; oldData.narodnost = newData.narodnost; oldData.pocet_psu = newData.pocet_psu; }
public void read_excel_table_temp(Majitele dataM, Psi dataP, string sourceFile, Int32 list) { Int32 tmp = 0; Excel.Application excelApp = new Excel.Application(); Excel.Workbook workbook; Excel.Worksheet worksheet; Excel.Range range; string databasePath = sourceFile; workbook = excelApp.Workbooks.Open(databasePath); worksheet = (Excel.Worksheet)workbook.Sheets.get_Item(list); Majitel temp_majitel = new Majitel(); Pes temp_pes = new Pes(); Int32 row = 0; range = worksheet.UsedRange; DataTable dt = new DataTable(); String temp = null; for (row = 2; row <= range.Rows.Count; row++) { DataRow dr = dt.NewRow(); temp = (range.Cells[row, 1] as Excel.Range).Value2; if (temp != null) // excel sloupec clenstvi { string tempStr = temp.ToString(); if (tempStr[0] == 'N') { temp_majitel.clen = "ne"; // neni clenem klubu } else { temp_majitel.clen = "ano"; // je clenem klubu } } else { temp_majitel.clen = "ano"; // policko by melo byt prazdne - mozna NULL ?! } //temp = (range.Cells[row, 2] as Excel.Range).Value2; temp_pes.ZavodLicence = SetTempFromExcel(range, row, 2); // excel sloupec zavod-licence-trening temp_pes.Jmeno = SetTempFromExcel(range, row, 3); // excel sloupec jmeno psa temp_pes.Plemeno = SetTempFromExcel(range, row, 4); // excel sloupec plemeno temp_pes.Poznamka = SetTempFromExcel(range, row, 5); // excel sloupec poznamka ZAVODNI SKUPINA !!!! temp_pes.Pohlavi = SetTempFromExcel(range, row, 6).ToLower(); // excel sloupec pohlavi temp_pes.Platba = SetTempIntFromExcel(range, row, 8); // excel sloupec platba temp_pes.Licence = SetTempFromExcel(range, row, 11); // excel sloupec licence temp = (range.Cells[row, 14] as Excel.Range).Value.ToShortDateString(); if (temp != null) // excel sloupec datum narozeni { temp_pes.Datum = DateTime.ParseExact(temp, Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern, Thread.CurrentThread.CurrentCulture); } else { temp_pes.Datum = DateTime.ParseExact(DateTime.MinValue.ToShortDateString(), Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern, Thread.CurrentThread.CurrentCulture); } temp_majitel.firstName = SetTempFromExcel(range, row, 15); // excel sloupec jmeno temp_majitel.narodnost = SetTempFromExcel(range, row, 17); // excel sloupec národnost temp_majitel.telefon = SetTempFromExcel(range, row, 18); // excel sloupec telefon temp_majitel.email = SetTempFromExcel(range, row, 19); // excel sloupec email temp_pes.Doplatit = 0; temp_majitel.id = dataM.GetNewId(); // přiřzení ID majiteli temp_majitel.penize = temp_pes.Platba + temp_pes.Doplatit; // součet zaplatil a má zaplatit temp_majitel.potvrzeni = "--"; // implicitně nastaven jako nezaplaceno temp_majitel.pocet_psu = 1; temp_pes.Id = dataP.GetNewId(); temp_pes.Majitel = temp_majitel.id; temp_pes.MajitelJmeno = temp_majitel.firstName; temp_pes.Skupina = 0; temp_pes.StartBeh1 = 0; temp_pes.StartBeh1 = 0; temp_pes.Diskval = "---"; temp_pes.AgilityA0 = 0; temp_pes.AgilityA1 = 0; temp_pes.SpeedA0 = 0; temp_pes.SpeedA1 = 0; temp_pes.EnduranceA0 = 0; temp_pes.EnduranceA1 = 0; temp_pes.EnthusiasmA0 = 0; temp_pes.EnthusiasmA1 = 0; temp_pes.IntelligenceA0 = 0; temp_pes.IntelligenceA1 = 0; temp_pes.AgilityB0 = 0; temp_pes.AgilityB1 = 0; temp_pes.SpeedB0 = 0; temp_pes.SpeedB1 = 0; temp_pes.EnduranceB0 = 0; temp_pes.EnduranceB1 = 0; temp_pes.EnthusiasmB0 = 0; temp_pes.EnthusiasmB1 = 0; temp_pes.IntelligenceB0 = 0; temp_pes.IntelligenceB1 = 0; temp_pes.Body1 = 0; temp_pes.Body2 = 0; temp_pes.Dvojice0 = 0; temp_pes.Dvojice1 = 0; temp_pes.Barva0 = ""; temp_pes.Barva1 = ""; tmp = dataM.FindSame(temp_majitel.firstName, temp_majitel.lastName, temp_majitel.email); if (tmp < 0) { dataM.Add(new Majitel(temp_majitel)); } else { Majitel editmajitel = dataM.GetMajitelById(tmp); editmajitel.penize += temp_majitel.penize; // přičtení majiteli platbu za dalšího psa editmajitel.pocet_psu++; dataM.Edit(tmp, editmajitel); temp_pes.Majitel = tmp; } dataP.Add(new Pes(temp_pes)); } workbook.Close(true, Missing.Value, Missing.Value); excelApp.Quit(); }
/// <summary> /// Prida majitele do databaze /// </summary> /// <param name="newMajitel"></param> public void Add(Majitel newMajitel) { this.majitele.Add(newMajitel); }