public static Inregistrare CreateInregistrare(string line) { string[] fields = line.Split(','); Inregistrare inregistrare = new Inregistrare(int.Parse(fields[0]), int.Parse(fields[1]), int.Parse(fields[2]), float.Parse(fields[3])); return(inregistrare); }
public void addNotaFaraPenalizare(int idS, int idT, float n, String feedback) { int id = nrNote() + 1; if (studentRepo.findOne(idS) != null) { if (temaRepo.findOne(idT) != null) { String nume = studentRepo.findOne(idS).Nume; Tema t = temaRepo.findOne(idT); Inregistrare i = new Inregistrare(id, idS, idT, n); IEnumerable <Inregistrare> it = catalogRepo.findAll(); foreach (Inregistrare inr in it) { if (inr.IdStudent == idS && inr.IdTema == idT) { throw new ValidationException("Studentul are deja o nota la aceasta tema \n"); } } catalogRepo.save(i); } else { throw new ValidationException("Id-ul dat pentru tema este inexistent \n"); } } else { throw new ValidationException("Id-ul dat pentru student este inexistent \n"); } }
private void btnModifica_Click(object sender, RoutedEventArgs e) { linieSelectataGrid = gridIntrastat.SelectedIndex; if (linieSelectataGrid == -1) { gridIntrastat.SelectedIndex = 0; } Declaratii declaratieSelectata = gridIntrastat.SelectedItem as Declaratii; // DataRowView dataRow = (DataRowView)gridIntrastat.SelectedItem; // int index = gridIntrastat.CurrentCell.Column.DisplayIndex; string tip = declaratieSelectata.Tip_Declaratie; string luna = declaratieSelectata.Luna; string an = declaratieSelectata.Anul; StreamReader stream = new StreamReader(FileLocation.System + "key\\chei.txt"); string line = ""; bool flag = false; while (true) { line = stream.ReadLine(); if (line == null) { break; } string[] keys = line.Split('\t'); string[] arrKeyTxt = new string[4]; if (keys[0].Length > 17) { arrKeyTxt = Inregistrare.DecodeKey(keys[0]); if (arrKeyTxt[0] == keys[1] && an == keys[2]) { flag = true; } } } stream.Close(); if (flag == true) { Frm_Intrastat frmIntrastat = new Frm_Intrastat(tip, luna, an); frmIntrastat.Show(); } else { Frm_Mesaj_Demo frmIntrastat = new Frm_Mesaj_Demo("Inregistrare"); frmIntrastat.Show(); } }
private void btnAdauga_Click(object sender, RoutedEventArgs e) { StreamReader stream = new StreamReader(FileLocation.System + "key\\chei.txt"); string line = ""; bool flag = false; while (true) { line = stream.ReadLine(); if (line == null) { break; } string[] keys = line.Split('\t'); string[] arrKeyTxt = new string[4]; if (keys[0].Length > 17) { arrKeyTxt = Inregistrare.DecodeKey(keys[0]); if (arrKeyTxt[0] == keys[1] && txtAn.Text == keys[2]) { flag = true; } } } stream.Close(); if (flag == true) { if (cmbTipDeclaratie.SelectionBoxItem.ToString() == "ACHIZITIE") { Frm_Intrastat frmIntrastat = new Frm_Intrastat("I", txtLuna.Text, txtAn.Text); frmIntrastat.Show(); } else { Frm_Intrastat frmIntrastat = new Frm_Intrastat("O", txtLuna.Text, txtAn.Text); frmIntrastat.Show(); } } else { Frm_Mesaj_Demo frmIntrastat = new Frm_Mesaj_Demo("Inregistrare"); frmIntrastat.Show(); } }
private void Row_DoubleClick(object sender, MouseButtonEventArgs e) { if (gridIntrastat.SelectedIndex < 0) { MessageBox.Show("Nici o linie nu este selectata!"); } else { int dataIndexNo = gridIntrastat.SelectedIndex; StreamReader stream = new StreamReader(FileLocation.System + "key\\chei.txt"); string line = ""; bool flag = false; while (true) { line = stream.ReadLine(); if (line == null) { break; } string[] keys = line.Split('\t'); string[] arrKeyTxt = new string[4]; if (keys[0].Length > 17) { arrKeyTxt = Inregistrare.DecodeKey(keys[0]); if (arrKeyTxt[0] == keys[1] && lista[dataIndexNo].Anul == keys[2]) { flag = true; } } } stream.Close(); if (flag == true) { Frm_Intrastat frmIntrastat = new Frm_Intrastat(lista[dataIndexNo].Tip_Declaratie, lista[dataIndexNo].Luna, lista[dataIndexNo].Anul); frmIntrastat.Show(); } else { Frm_Mesaj_Demo frmIntrastat = new Frm_Mesaj_Demo("Inregistrare"); frmIntrastat.Show(); } } }
private void BtnValidare_Click(object sender, RoutedEventArgs e) { if (TxtKey.Text == "") { MessageBox.Show("Campul Chei de inregistrare nu poate fi gol"); } else { try { string txtkey = TxtKey.Text.Replace('\r', ' '); string[] keys = txtkey.Split('\n'); for (int i = keys.Length - 1; i >= 0; i--) { if (keys[i] != " " && keys[i] != "" && keys[i] != null) { keys[i] = keys[i].Trim(); } } for (int i = keys.Length - 1; i >= 0; i--) { string[] arrKeyTxt = new string[4]; if (keys[i].Length > 17) { arrKeyTxt = Inregistrare.DecodeKey(keys[i]); if (arrKeyTxt[0] == CodFiscal.Text.Trim()) { WriteInFile(keys[i], CodFiscal.Text, arrKeyTxt[2]); MessageBox.Show(string.Format("Cheia: {0} a fost inregistrata cu success!", keys[i])); } else { MessageBox.Show(string.Format("Cheia: {0} era INVALIDA sau Codul fiscal nu coincide!", keys[i])); } } } } catch { MessageBox.Show(string.Format("Intregistrarea a esuat!")); } } }
public void addNotaCuPenalizare(int idS, int idT, float n, String feedback) { int id = nrNote() + 1; if (studentRepo.findOne(idS) != null) { if (temaRepo.findOne(idT) != null) { String nume = studentRepo.findOne(idS).Nume; Tema t = temaRepo.findOne(idT); if (t.Deadline < GetLabNumber()) { int diff = GetLabNumber() - t.Deadline; for (int j = 1; j <= diff; j++) { n = (float)(n - 2.5); } } if (n < 0) { n = 0; } Inregistrare i = new Inregistrare(id, idS, idT, n); IEnumerable <Inregistrare> it = catalogRepo.findAll(); foreach (Inregistrare inr in it) { if (inr.IdStudent == idS && inr.IdTema == idT) { throw new ValidationException("Studentul are deja o nota la aceasta tema \n"); } } catalogRepo.save(i); } else { throw new ValidationException("Id-ul dat pentru tema este inexistent \n"); } } else { throw new ValidationException("Id-ul dat pentru student este inexistent \n"); } }