Ejemplo n.º 1
0
        private void mSaveAs_Click(object sender, EventArgs e)
        {
            aircraft = new AircraftType {
                Aircrafts = db.Aircrafts.Local.ToList()
            };
            frmProcessFile serializeFrm = new frmProcessFile();

            if (serializeFrm.ShowDialog() == DialogResult.OK)
            {
                SaveFileDialog saveFile = InitializeSaveFile(serializeFrm.TypeSerialization.ToLower());
                if (saveFile.ShowDialog(this) == DialogResult.OK)
                {
                    if (serializeFrm.TypeSerialization.ToLower() == "txt")
                    {
                        SaveTXT(saveFile, aircraft);
                    }
                    else if (serializeFrm.TypeSerialization.ToLower() == "soap")
                    {
                        SaveSOAP(saveFile, aircraft.Aircrafts.ToArray());
                    }
                    else
                    {
                        SaveOpenFile <ISerilizable>(serializeFrm.TypeSerialization, true, saveFile, null, aircraft);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void mOpenFrom_Click(object sender, EventArgs e)
        {
            frmProcessFile serializeFrm = new frmProcessFile();

            if (serializeFrm.ShowDialog() == DialogResult.OK)
            {
                cbType.SelectedIndex = -1;
                OpenFileDialog openFile = InitializeOpenFile("zip");
                if (openFile.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        if (serializeFrm.TypeSerialization.ToLower() == "txt")
                        {
                            OpenTXT(openFile);
                        }
                        else if (serializeFrm.TypeSerialization.ToLower() == "soap")
                        {
                            aircraft.Aircrafts = OpenSOAP(openFile).ToList();
                        }
                        else
                        {
                            aircraft = SaveOpenFile <ISerilizable>(serializeFrm.TypeSerialization, false, null, openFile, null);
                        }
                        db.Aircrafts.RemoveRange(db.Aircrafts);
                        db.Aircrafts.AddRange(aircraft.Aircrafts);
                        db.SaveChanges();
                    }
                    catch (Exception)
                    {
                        aircraft = new AircraftType()
                        {
                            Aircrafts = new List <Aircraft>()
                        };
                    }
                }
            }
        }