Esempio n. 1
0
        private Termin[] GenerateTerminArray(int k, int max)
        {
            Database  db = new Database();
            DataSet   ds = db.selectTermin();
            DataTable dt = ds.Tables["Termine"];

            Termin[] termin = new Termin[dt.Rows.Count];
            int      x      = 0;

            foreach (DataRow row in dt.Rows)
            {
                termin[x].Id          = x;
                termin[x].Bezeichnung = row["tn_bez"].ToString();
                termin[x].Von         = (DateTime)row["tn_von"];
                termin[x].Bis         = (DateTime)row["tn_bis"];
                x++;
            }
            return(termin);
        }
Esempio n. 2
0
        private void MaterialRaisedButton1_Click(object sender, EventArgs e)
        {
            if (!txtTitel.Equals("") || !txtTitel.Equals(" "))
            {
                if (rightDateVon == true && rightDateBis == true && GanzTag == false)
                {
                    int vonInMin = (Convert.ToInt32(txtVon.Text.Substring(0, 2).ToString()) * 60) + (Convert.ToInt32(txtVon.Text.Substring(3, 2).ToString()));
                    int bisInMin = (Convert.ToInt32(txtBis.Text.Substring(0, 2).ToString()) * 60) + (Convert.ToInt32(txtBis.Text.Substring(3, 2).ToString()));
                    if (edit)
                    {
                        for (int i = 0; i < f1.arrTermine.Count; i++)
                        {
                            if (f1.arrTermine[i].TerID == id)
                            {
                                Termin t = f1.arrTermine[i];

                                t.TerNname        = txtTitel.Text;
                                t.TerBeschreibung = txtNotizen.Text;
                                t.TerGanztaegig   = false;
                                t.VonInMin        = vonInMin;
                                t.BisInMin        = bisInMin;
                            }
                        }
                    }
                    else
                    {
                        f1.arrTermine.Add(new Termin(txtTitel.Text, txtNotizen.Text, jahr, monat, tag, false, vonInMin, bisInMin));
                    }
                    try
                    {
                        FileStream fs = new FileStream(Application.StartupPath + "\\Termine.xml", FileMode.Create, FileAccess.Write, FileShare.None);
                        serializer.Serialize(fs, f1.arrTermine);
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    this.Close();
                }
                else if (GanzTag == true)
                {
                    if (edit)
                    {
                        for (int i = 0; i < f1.arrTermine.Count; i++)
                        {
                            if (f1.arrTermine[i].TerID == id)
                            {
                                Termin t = f1.arrTermine[i];

                                t.TerNname        = txtTitel.Text;
                                t.TerBeschreibung = txtNotizen.Text;
                                t.TerGanztaegig   = true;
                                t.VonInMin        = 0;
                                t.BisInMin        = 0;
                            }
                        }
                    }
                    else
                    {
                        f1.arrTermine.Add(new Termin(txtTitel.Text, txtNotizen.Text, jahr, monat, tag, true, 0, 0));
                    }

                    try
                    {
                        FileStream fs = new FileStream(Application.StartupPath + "\\Termine.xml", FileMode.Create, FileAccess.Write, FileShare.None);
                        serializer.Serialize(fs, f1.arrTermine);
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    this.Close();
                }
            }
        }