Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Visitor currentVisitor = new Visitor(fio, number, roomnumber, Convert.ToUInt16(capacityroom), rangroom, Convert.ToUInt16(howlong));

            ExcelSerializer excelSerializer = new ExcelSerializer();

            excelSerializer.isExisted();
            excelSerializer.Write(currentVisitor);
            excelSerializer.Close();

            WordSerializer wordSerializer = new WordSerializer();

            wordSerializer.isExisted();
            wordSerializer.Write(currentVisitor);
            wordSerializer.Close();
            spisok.addvisitor(currentVisitor);

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            /*fbd.SelectedPath = "E:\\Ucheba\\Interfaces\\Hotel_Project\\Hotel_Project\\bin\\Debug\\";
             * if (fbd.ShowDialog() == DialogResult.Cancel)
             *  return;*/
            SaveFileDialog svf = new SaveFileDialog();

            svf.Filter = "XML files(*.xml)|*.xml|All files(*.*)|*.*";
            if (svf.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string filename = svf.FileName;

            using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate))
            {
                serial.Serialize(fs, spisok);
            }
            using (StreamWriter wlog = new StreamWriter("log.txt", true))
            {
                wlog.WriteLine("{0} | {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString() + " | " + "В базу добавлен новый клиент - " + fio);
            }
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Visitor currentVisitor = new Visitor(fio, number, roomnumber, Convert.ToUInt16(capacityroom), rangroom, Convert.ToUInt16(howlong));

            ExcelSerializer excelSerializer = new ExcelSerializer();

            excelSerializer.isExisted();
            excelSerializer.Write(currentVisitor);
            excelSerializer.Close();

            WordSerializer wordSerializer = new WordSerializer();

            wordSerializer.isExisted();
            wordSerializer.Write(currentVisitor);
            wordSerializer.Close();
            spisok.addvisitor(currentVisitor);

            SaveFileDialog svf = new SaveFileDialog();

            svf.Filter = "XML files(*.xml)|*.xml|All files(*.*)|*.*";
            if (svf.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string filename = svf.FileName;

            using (FileStream fs = new FileStream(filename, FileMode.Create))
            {
                serial.Serialize(fs, spisok);
            }
            using (StreamWriter wlog = new StreamWriter("log.txt", true))
            {
                wlog.WriteLine("{0} | {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString() + " | " + "В базу добавлен новый клиент - " + fio);
            }

            /*DataSet ds = new DataSet();
             * ds.WriteXml(filename);*/
        }