コード例 #1
0
        public List <Eveniment> IncarcaListaDeEvenimente()
        {
            // List<string> marca = new List<string>();
            List <Eveniment> e      = new List <Eveniment>();
            List <Masina>    masina = new List <Masina>();

            using (var cn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename" +
                                              @"='C:\Users\Andrei\Documents\GitHub\pssc-proiect\IterfataUtilizator\App_Data\Users.mdf';Integrated Security=True"))
            {
                string _sql = @"SELECT * FROM [dbo].[ParcAuto] ";
                var    cmd  = new SqlCommand(_sql, cn);
                cn.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string[] tokens = reader["DetaliiEveniment"].ToString().Split('"');
                        //  marca.Add(tokens[13]);
                        string tip   = Regex.Match(tokens[8], @"\d+").Value;
                        Masina m     = new Masina(new PlainText(tokens[5]), (TipMasina)Enum.Parse(typeof(TipMasina), tip), new PlainText(tokens[13]), new PlainText(tokens[67]), new PlainText(tokens[19]), new PlainText(tokens[61]), new PlainText(tokens[25]), new PlainText(tokens[37]), new PlainText(tokens[51]), new PlainText(tokens[49]), new PlainText(tokens[43]), new PlainText(tokens[31]));
                        string stare = Regex.Match(tokens[70], @"\d+").Value;
                        //object detalii = JsonConvert.DeserializeObject<MasinaDes.RootObject>(reader["DetaliiEveniment"].ToString());
                        // object detalii = JsonConvert.DeserializeObject<List<Eveniment>>(String.Format("{0}", reader["DetaliiEveniment"]));
                        m.stare = (StareMasina)Enum.Parse(typeof(StareMasina), stare);
                        Eveniment ev = new Eveniment(new PlainText(reader["IdRadacina"].ToString()), (TipEveniment)Enum.Parse(typeof(TipEveniment), reader["TipEveniment"].ToString()), m);
                        e.Add(ev);
                    }
                }
            }
            return(e);
        }
コード例 #2
0
        public bool Trimite(Eveniment e)
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: "hello",
                                         durable: false,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);

                    string message = e.Tip.ToString();
                    var    body    = Encoding.UTF8.GetBytes(message);

                    channel.BasicPublish(exchange: "",
                                         routingKey: "hello",
                                         basicProperties: null,
                                         body: body);
                    Console.WriteLine(" [x] Sent {0}", message);
                }

            Console.WriteLine(" Press [enter] to exit.");
            return(true);
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "ID_NumeEveniment,ID_NumeResursa,NumarZile,ID_Data,Ora,ID_TipPlata")] Eveniment eveniment, string[] selectedMembrii)
        {
            //if (eveniment.ID_NumeResursa == "Disponibil")
            //  {
            //            if (ModelState.IsValid)
            //         {
            //              string test = eveniment.ID_NumeResursa;
            //            if (eveniment.Resurse.ID_Status == "Disponibil")
            //              {

            if (selectedMembrii != null)
            {
                eveniment.Membriis = new List <Membrii>();
                foreach (var membru in selectedMembrii)
                {
                    var membruToAdd = db.Membriis.Find(membru);
                    eveniment.Membriis.Add(membruToAdd);
                }
            }
            if (ModelState.IsValid)
            {
                db.Eveniments.Add(eveniment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_TipPlata    = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie", eveniment.ID_TipPlata);
            ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa", eveniment.ID_NumeResursa);

            PopulateAssignedMembriiDaa(eveniment);
            return(View(eveniment));
        }
コード例 #4
0
        public static void Citeste()
        {
            string line = null;

            while ((line = sr.ReadLine()) != null)
            {
                string[]     s          = line.Split(';');
                string       idRadacina = s[0];
                TipEveniment t;

                if (s[1] == "ImprumutareCarte")
                {
                    t = TipEveniment.ImprumutareCarte;
                }
                else if (s[1] == "PrelungireTermen")
                {
                    t = TipEveniment.PrelungireTermen;
                }
                else if (s[1] == "RestituireCarte")
                {
                    t = TipEveniment.RestituireCarte;
                }
                else
                {
                    t = TipEveniment.RezervareCarte;
                }

                string detalii = s[2];

                Eveniment e = new Eveniment(idRadacina, t, detalii);
                events.Add(e);
            }
            sr.Close();
        }
コード例 #5
0
 public void SalvareEvenimente(Eveniment evenimenteNoi)
 {
     string detalii      = JsonConvert.SerializeObject(evenimenteNoi.Detalii);
     var    tipEveniment = evenimenteNoi.Tip;
     var    idEveniment  = evenimenteNoi.Id.ToString();
     var    idRadacina   = evenimenteNoi.IdRadacina.ToString();
 }
コード例 #6
0
ファイル: WriteRepository.cs プロジェクト: PopaDani/PSSC-2017
        public void SalvareEvenimente(Eveniment evenimenteNoi)
        {
            string detalii      = JsonConvert.SerializeObject(evenimenteNoi.Detalii);
            var    tipEveniment = evenimenteNoi.Tip;
            var    idEveniment  = evenimenteNoi.Id.ToString();
            var    idRadacina   = evenimenteNoi.IdRadacina.ToString();

            using (var cn = new SqlConnection(connection))
            {
                string _sql = @"INSERT INTO [dbo].[CatalogProduse](IdEveniment,TipEveniment,DetaliiEveniment,IdRadacina)" +
                              "VALUES (@idEveniment,@tipEveniment,@detalii,@IdRadacina)";
                var cmd = new SqlCommand(_sql, cn);
                cmd.Parameters
                .Add(new SqlParameter("@idEveniment", SqlDbType.VarChar))
                .Value = idEveniment;
                cmd.Parameters
                .Add(new SqlParameter("@tipEveniment", SqlDbType.VarChar))
                .Value = tipEveniment;
                cmd.Parameters
                .Add(new SqlParameter("@detalii", SqlDbType.VarChar))
                .Value = detalii;
                cmd.Parameters
                .Add(new SqlParameter("@IdRadacina", SqlDbType.VarChar))
                .Value = idRadacina;
                cn.Open();
                var reader = cmd.ExecuteReader();
            }
        }
コード例 #7
0
ファイル: Settings.cs プロジェクト: norbertgagyi/ThorV1
        public static Eveniment Eveniment(string caleEveniment)
        {
            Eveniment e = new Eveniment();

            if (File.Exists(CaleFisierInfoEveniment(caleEveniment)))
            {
                string[] linii = File.ReadAllLines(CaleFisierInfoEveniment(caleEveniment));

                e.Id             = int.Parse(linii[0]);
                e.Stare          = linii[1];
                e.Nume_Firma     = linii[2];
                e.Denumire       = linii[3];
                e.Tip            = linii[4];
                e.Data_Eveniment = DateTime.Parse(linii[5]);

                e.Note = "";

                for (int i = 6; i < linii.Length; i++)
                {
                    e.Note += linii[i];
                    e.Note += "\r\n";
                }
            }

            e.Cai_Documente = new List <string>();

            e.Cai_Documente = Directory.GetFiles(CaleDocumenteEveniment(caleEveniment)).ToList();

            return(e);
        }
コード例 #8
0
 protected void PublicaEveniment(Eveniment eveniment)
 {
     _evenimenteNoi.Add(eveniment);
     if (EvenimentMeci != null)
     {
         EvenimentMeci(this, eveniment);
     }
 }
コード例 #9
0
 protected void PublicaEveniment(Eveniment eveniment)
 {
     _evenimenteNoi.Add(eveniment);
     if (EvenimentInscriere != null)
     {
         EvenimentInscriere(this, eveniment);
     }
 }
コード例 #10
0
        public ActionResult DeleteConfirmed(string id)
        {
            Eveniment eveniment = db.Eveniments.Find(id);

            db.Eveniments.Remove(eveniment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #11
0
 protected void PublicaEveniment(Eveniment eveniment)
 {
     events.Add(eveniment);
     if (Eveniment != null)
     {
         Eveniment(this, eveniment);
     }
 }
コード例 #12
0
        //Citeste un fisier XML si returneaza o lista de structuri Eveniment
        //Parametrii:
        //- numeFisier (string) = numele fisierului XML din care citesc
        public static List<Eveniment> citesteEvenimente(string numeFisier)
        {
            List<Eveniment> lista = new List<Eveniment>();

            if (File.Exists(numeFisier) == true)
            {
                XmlDocument fisierXML = new XmlDocument();

                fisierXML.Load(numeFisier);

                XmlNode root = fisierXML.SelectSingleNode("evenimente");

                foreach (XmlNode elem in root.SelectNodes("eveniment"))
                {
                    Eveniment ev = new Eveniment();

                    ev.id = Convert.ToInt32(elem.Attributes["id"].Value);
                    ev.data = Convert.ToDateTime(elem.Attributes["data"].Value);

                    switch (elem.Attributes["perioada"].Value)
                    {
                        case "Lunar":
                            ev.perioada = PerioadaEveniment.Lunar;
                            break;
                        case "Saptamanal":
                            ev.perioada = PerioadaEveniment.Saptamanal;
                            break;
                        case "OdataLaXZile":
                            ev.perioada = PerioadaEveniment.OdataLaXZile;
                            ev.xZile = Convert.ToInt32(elem.Attributes["xZile"].Value);
                            break;
                        case "AltTip":
                            ev.perioada = PerioadaEveniment.AltTip;
                            break;
                    }

                    switch (elem.Attributes["tipEveniment"].Value)
                    {
                        case "Cheltuiala":
                            ev.tipEveniment = TipEveniment.Cheltuiala;
                            break;
                        case "Venit":
                            ev.tipEveniment = TipEveniment.Venit;
                            break;
                    }

                    ev.suma = Convert.ToInt32(elem.Attributes["suma"].Value);
                    ev.detalii = elem.InnerText;

                    lista.Add(ev);
                }
            }
            //else
                //MessageBox.Show("Fisierul " + numeFisier + " nu exista.");

            return lista;
        }
コード例 #13
0
        // GET: /Eveniment/Create
        public ActionResult Create()
        {
            var eveniment = new Eveniment();

            eveniment.Membriis = new List <Membrii>();
            PopulateAssignedMembriiDaa(eveniment);

            ViewBag.ID_TipPlata    = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie");
            ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa");

            return(View());
        }
コード例 #14
0
        public static async void Write(Eveniment e)
        {
            sr = new StreamReader("C:\\Users\\Cosmina\\Desktop\\PSSC-master\\Biblioteca\\evenimente.txt");
            string s;

            s = sr.ReadToEnd();
            sr.Close();
            sw = new StreamWriter("C:\\Users\\Cosmina\\Desktop\\PSSC-master\\Biblioteca\\evenimente.txt");
            sw.Write(s);
            sw.WriteLine(e.ToString());
            sw.Close();
        }
コード例 #15
0
 public ActionResult Edit([Bind(Include = "ID_NumeEveniment,ID_NumeResursa,NumarZile,ID_Data,Ora,ID_TipPlata")] Eveniment eveniment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eveniment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID_TipPlata    = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie", eveniment.ID_TipPlata);
     ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa", eveniment.ID_NumeResursa);
     return(View(eveniment));
 }
コード例 #16
0
 protected void PublicaEveniment(Eveniment eveniment)
 {
     _evenimenteNoi.Add(eveniment);
     //EvenimentMeci?.Invoke(this, eveniment);
     if (_magistralaEveniment != null)
     {
         _magistralaEveniment.Trimite(eveniment);
     }
     else
     {
         MagistralaEvenimente.Instanta.Value.Trimite(eveniment);
     }
 }
コード例 #17
0
        // GET: /Eveniment/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Eveniment eveniment = db.Eveniments.Find(id);

            if (eveniment == null)
            {
                return(HttpNotFound());
            }
            return(View(eveniment));
        }
コード例 #18
0
        public override Carte Proceseaza(ComandaRestituieCarte comanda)
        {
            for (int i = 0; i < MagistralaEvenimente.CartiUser.Count; i++)
            {
                if (MagistralaEvenimente.CartiUser[i].Titlu == comanda.Titlu)
                {
                    MagistralaEvenimente.CartiUser.RemoveAt(i);
                }
            }

            Eveniment e = new Eveniment("0", TipEveniment.RestituireCarte, comanda.Titlu);

            SalvareEveniment.Write(e);
            return(null);
        }
コード例 #19
0
        // GET: /Eveniment/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Eveniment eveniment = db.Eveniments.Find(id);

            if (eveniment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ID_TipPlata    = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie", eveniment.ID_TipPlata);
            ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa", eveniment.ID_NumeResursa);
            return(View(eveniment));
        }
コード例 #20
0
        private void PopulateAssignedMembriiDaa(Eveniment eveniment)
        {
            var allMembrii      = db.Membriis;
            var evenimentMembru = new HashSet <string>(eveniment.Membriis.Select(c => c.ID_Username));
            var viewModel       = new List <AssignedMembriiDaa>();

            foreach (var membru in allMembrii)
            {
                viewModel.Add(new AssignedMembriiDaa
                {
                    ID_Username = membru.ID_Username,
                    Assigned    = evenimentMembru.Contains(membru.ID_Username)
                });
            }
            ViewBag.Membrii = viewModel;
        }
コード例 #21
0
        public override Carte Proceseaza(ComandaRezervaCarte comanda)
        {
            Carte c = null;
            ProcesatorCautaCarte p   = new ProcesatorCautaCarte();
            ComandaCautaCarte    cmd = new ComandaCautaCarte();

            cmd.Titlu = comanda.Titlu;
            c         = p.Proceseaza(cmd);
            c.Stare   = StareCarte.Rezervata;

            MagistralaEvenimente.CartiUser.Add(c);

            Eveniment e = new Eveniment(c.Id.ToString(), TipEveniment.RezervareCarte, c.Titlu);

            SalvareEveniment.Write(e);
            return(null);
        }
コード例 #22
0
        public override Carte Proceseaza(ComandaImprumutaCarte comanda)
        {
            Carte c = null;
            ProcesatorCautaCarte p   = new ProcesatorCautaCarte();
            ComandaCautaCarte    cmd = new ComandaCautaCarte();

            cmd.Titlu      = comanda.Titlu;
            c              = p.Proceseaza(cmd);
            c.Stare        = StareCarte.Imprumutata;
            c.DataImprumut = DateTime.Now;

            MagistralaEvenimente.CartiUser.Add(c);
            Eveniment e = new Eveniment(c.Id.ToString(), TipEveniment.ImprumutareCarte, c.Titlu);

            SalvareEveniment.Write(e);
            return(null);                            // trebuie verificat daca cartea e deja imprumutata
        }
コード例 #23
0
        static void Main(string[] args)
        {
            Eveniment ev = new Eveniment(); //crearea instantelor
            A         a  = new A();
            B         b  = new B();

            //adaugam rutinele de tratare la lisa de evenimente

            ev.activat += new DelegatTratareEveniment(handler);

            ev.activat += new DelegatTratareEveniment(a.AHandler);

            ev.activat += new DelegatTratareEveniment(b.BHandler);

            ev.Actiune();                                          //lansam evenimentul

            ev.activat -= new DelegatTratareEveniment(a.AHandler); //eliminarea unei rutine de tratare
        }
コード例 #24
0
ファイル: Send.cs プロジェクト: PopaDani/PSSC-2017
        public void TrimiteEveniment(Eveniment e)
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);

                    string message = JsonConvert.SerializeObject(e.Detalii).ToString();
                    var    body    = Encoding.UTF8.GetBytes(message);

                    channel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body);
                    //  Console.WriteLine(" [x] Sent {0}", message);
                }
        }
コード例 #25
0
        public ActionResult AddEvents([DataSourceRequest] DataSourceRequest request, Events ev)//adaugare in tabela eveniment
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var evt = new Eveniment
                    {
                        Denumire     = ev.Denumire,
                        Data_Start   = ev.Data_Start,
                        Data_Sfarsit = ev.Data_Sfarsit,
                        Activ        = false,
                        Id_MO        = 2
                    };

                    pl.Eveniments.Add(evt);
                    pl.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                catch (Exception ex)
                {
                    ViewData["error"] = ex.Message;
                }

                finally
                {
                    pl.Dispose();
                }
            }

            else//daca modelul nu este vaid, vedem ce problema a aparut
            {
                var message = string.Join(" | ", ModelState.Values
                                          .SelectMany(v => v.Errors)
                                          .Select(e => e.ErrorMessage));
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message));
            }

            return(RedirectToAction("Index"));
        }
コード例 #26
0
ファイル: WriteRepository.cs プロジェクト: Bianca3/PSSC-2017
        public void SalvareEvenimente(Eveniment evenimenteNoi)
        {
            string id           = evenimenteNoi.Id.ToString();
            string detalii      = JsonConvert.SerializeObject(evenimenteNoi);
            var    tipEveniment = evenimenteNoi.Tip;
            var    idRadacina   = evenimenteNoi.IdRadacina.ToString();

            using (var con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename" +
                                               @"='C:\Users\Bianca\Documents\Proiectarea sistemelor software complexe\Proiect\Proiect\" +
                                               @"WebMvcLibrarie\App_Data\DatabaseCarti.mdf';Integrated Security=True"))
            {
                string sql = @"INSERT INTO [dbo].[Evenimente] VALUES (@id,@detalii,@tipEveniment,@idRad)";
                var    cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@detalii", detalii);
                cmd.Parameters.AddWithValue("@tipEveniment", tipEveniment.ToString());
                cmd.Parameters.AddWithValue("@idRad", idRadacina);
                con.Open();
                int nrinreg = cmd.ExecuteNonQuery();
            }
        }
コード例 #27
0
        public override Carte Proceseaza(ComandaPrelungireTermen comanda)
        {
            Carte c = null;
            ProcesatorCautaCarte p   = new ProcesatorCautaCarte();
            ComandaCautaCarte    cmd = new ComandaCautaCarte();

            cmd.Titlu = comanda.Titlu;
            c         = p.Proceseaza(cmd);
            c.Termen  = c.Termen + 2;

            for (int i = 0; i < MagistralaEvenimente.CartiUser.Count; i++)
            {
                if (MagistralaEvenimente.CartiUser[i].Titlu == comanda.Titlu)
                {
                    MagistralaEvenimente.CartiUser[i] = c;
                }
            }
            Eveniment e = new Eveniment(c.Id.ToString(), TipEveniment.PrelungireTermen, c.Titlu);

            SalvareEveniment.Write(e);
            return(null);
        }
コード例 #28
0
        public void SalvareEvenimente(Eveniment evenimentNoi)
        {
            //  List<Eveniment> toateEvenimentele = IncarcaListaDeEvenimente();
            //  toateEvenimentele.AddRange(evenimentNoi);

            string detalii      = JsonConvert.SerializeObject(evenimentNoi.Detalii);
            var    tipEveniment = evenimentNoi.Tip;
            // detalii =
            var IdRadacina  = evenimentNoi.IdRadacina.Id;
            var IdEveniment = evenimentNoi.Id.Id;

            ///Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Paul\Documents\GitHub\ProjectsAn4\AtelierAuto\AtelierAuto\App_Data\MecanicDatabase.mdf;Integrated Security=True
            using (var cn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename" +
                                              @"='C:\Users\Paul\Documents\GitHub\ProjectsAn4\AtelierAuto\AtelierAuto\App_Data\MecanicDatabase.mdf';Integrated Security=True")) //incerc si fara '
            {
                string _sql = @"INSERT INTO [dbo].[Comanda](IdEveniment,TipEveniment,DetaliiEveniment,IdRadacina)" +
                              "VALUES (@IdEveniment,@tipEveniment,@detalii,@IdRadacina)";
                var cmd = new SqlCommand(_sql, cn);
                cmd.Parameters
                .Add(new SqlParameter("@tipEveniment", SqlDbType.VarChar))
                .Value = tipEveniment;
                cmd.Parameters
                .Add(new SqlParameter("@detalii", SqlDbType.VarChar))
                .Value = detalii;
                cmd.Parameters
                .Add(new SqlParameter("@IdRadacina", SqlDbType.VarChar))
                .Value = IdRadacina;
                cmd.Parameters
                .Add(new SqlParameter("@IdEveniment", SqlDbType.VarChar))
                .Value = IdRadacina;
                cn.Open();
                var reader = cmd.ExecuteReader();

                TrimiteNotificareaLaMecanic(); //RABBIT MQ

                //scrie in baza de date evenimentele// sau in fisier : scrie - continut - fisier
            }
        }
コード例 #29
0
        private void RedaEveniment(Eveniment e)
        {
            switch (e.Tip)
            {
            case TipEveniment.AdaugareCarte:
                AplicaAdaug(e.ToGeneric <Carte>());
                break;

            case TipEveniment.CumparareCarte:
                AplicaCumpar(e.ToGeneric <Carte>());
                break;

            case TipEveniment.ImprumutareCarte:
                AplicaImprumut(e.ToGeneric <Carte>());
                break;

            case TipEveniment.RestituireCarte:
                AplicaRestituie(e.ToGeneric <Carte>());
                break;

            default:
                throw new EvenimentNecunoscutExceptie();
            }
        }
コード例 #30
0
ファイル: WriteRepository.cs プロジェクト: Bianca3/PSSC-2017
 public void StergeEvenimente(Eveniment evenimenteNoi)
 {
 }
コード例 #31
0
ファイル: WriteRepository.cs プロジェクト: Bianca3/PSSC-2017
 public void ActualizareEvenimente(Eveniment evenimenteNoi)
 {
 }
コード例 #32
0
        private Eveniment citesteEveniment(int id)
        {
            Eveniment ev = new Eveniment();
            ev.id = id;

            ev.data = dtpData.Value;

            double sumaOut;
            if (!Double.TryParse(txtSuma.Text, out sumaOut))
            {
                throw new InvalidEvenimentException("Suma lipseste sau este intr-un format incorect!");
            }
            ev.suma = sumaOut;

            if (cmbPerioada.SelectedItem == null)
            {
                throw new InvalidEvenimentException("Tip perioada neselectat!");
            }

            switch (cmbPerioada.SelectedItem.ToString())
            {
                case "Lunar":
                    ev.perioada = PerioadaEveniment.Lunar;
                    break;
                case "Saptamanal":
                    ev.perioada = PerioadaEveniment.Saptamanal;
                    break;
                case "Odata la n zile":
                    ev.perioada = PerioadaEveniment.OdataLaXZile;
                    int xZileOut; if (!int.TryParse(txtOdataLa.Text, out xZileOut))
                    {
                        throw new InvalidEvenimentException("Format incorect numar zile");
                    }
                    ev.xZile = xZileOut;
                    break;
                case "Alt tip":
                    ev.perioada = PerioadaEveniment.AltTip;
                    break;
                default:
                    throw new Exception("Alegeti o perioada");
            }

            if (cmbTipEveniment.SelectedItem == null)
            {
                throw new InvalidEvenimentException("Tip eveniment neselectat!");
            }

            switch (cmbTipEveniment.SelectedItem.ToString())
            {
                case "Cheltuiala":
                    ev.tipEveniment = TipEveniment.Cheltuiala;
                    break;
                case "Venit":
                    ev.tipEveniment = TipEveniment.Venit;
                    break;
            }

            ev.detalii = txtDetalii.Text;

            return ev;
        }