コード例 #1
0
        public bool ControlDias(string dia) //controlar que no se metan los mismos dias
        {
            bool correcto;

            if (dia.Length == 10)
            {
                using (var Context = new MyDbContext())
                {
                    if (!moduloInicio.Existe("select FechaFestivo from pyme.festivoes where FechaFestivo='" + dia + "';"))
                    {
                        Festivo NuevoFestivo = new Festivo();
                        NuevoFestivo.FechaFestivo = dia;
                        Context.Festivos.Add(NuevoFestivo);
                        Context.SaveChanges();
                    }
                }
                correcto = true;
            }
            else
            {
                MessageBox.Show("error dato " + dia + " dato no cargado", "CUIDADO", MessageBoxButtons.OK);
                correcto = false;
            }

            return(correcto);
        }
コード例 #2
0
ファイル: BdFestivos.cs プロジェクト: ander74/Orion
        /*================================================================================
         * GET FESTIVOS POR AÑO
         *================================================================================*/
        public static ObservableCollection <Festivo> GetFestivosPorAño(int año)
        {
            // Creamos la lista y el comando que extrae las líneas.
            ObservableCollection <Festivo> lista = new ObservableCollection <Festivo>();

            using (OleDbConnection conexion = new OleDbConnection(App.Global.CadenaConexion))
            {
                //string comandoSQL = "SELECT * FROM Festivos WHERE Año=? ORDER BY Fecha;";
                string comandoSQL = "GetFestivosPorAño";

                OleDbCommand comando = new OleDbCommand(comandoSQL, conexion);
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("Año", año);
                OleDbDataReader lector = null;

                try {
                    conexion.Open();

                    lector = comando.ExecuteReader();

                    while (lector.Read())
                    {
                        Festivo festivo = new Festivo(lector);
                        lista.Add(festivo);
                        festivo.Nuevo      = false;
                        festivo.Modificado = false;
                    }
                } catch (Exception ex) {
                    Utils.VerError("BdFestivos.GetFestivosPorAño", ex);
                } finally {
                    lector.Close();
                }
            }
            return(lista);
        }
コード例 #3
0
 public FestivoForm(long oid, Festivo festivo, Form parent)
     : base(oid, new object[1] {
     festivo
 }, true, parent)
 {
     InitializeComponent();
 }
コード例 #4
0
ファイル: BdFestivos.cs プロジェクト: ander74/Orion
        /*================================================================================
         * GET FESTIVOS
         *================================================================================*/
        public static List <Festivo> GetFestivos()
        {
            // Creamos la lista y el comando que extrae las líneas.
            List <Festivo> lista = new List <Festivo>();

            using (OleDbConnection conexion = new OleDbConnection(App.Global.CadenaConexion)) {
                string comandoSQL = "SELECT * FROM Festivos ORDER BY Fecha;";

                OleDbCommand    comando = new OleDbCommand(comandoSQL, conexion);
                OleDbDataReader lector  = null;

                try {
                    conexion.Open();
                    lector = comando.ExecuteReader();
                    while (lector.Read())
                    {
                        Festivo festivo = new Festivo(lector);
                        lista.Add(festivo);
                        festivo.Nuevo      = false;
                        festivo.Modificado = false;
                    }
                } catch (Exception ex) {
                    Utils.VerError("BdFestivos.GetFestivosPorMes", ex);
                } finally {
                    lector.Close();
                }
            }
            return(lista);
        }
コード例 #5
0
 public FestivoEditForm(Festivo item, Form parent)
     : base(item, parent)
 {
     InitializeComponent();
     SetFormData();
     _mf_type = ManagerFormType.MFEdit;
 }
コード例 #6
0
 private void DeleteFestivo_BT_Click(object sender, EventArgs e)
 {
     if (Festivos_DGW.CurrentRow != null)
     {
         Festivo.Delete(ActiveOID);
         RefreshMainData();
     }
 }
コード例 #7
0
        protected override void GetFormSourceData(long oid, object[] parameters)
        {
            _entity = (Festivo)parameters[0];

            if (_entity == null)
            {
                _entity = Festivo.Get(oid, false);
                _entity.BeginEdit();
            }
        }
コード例 #8
0
ファイル: BdFestivos.cs プロジェクト: ander74/Orion
        /*================================================================================
         * GUARDAR FESTIVOS
         *================================================================================*/
        public static void GuardarFestivos(IEnumerable <Festivo> lista)
        {
            // Si la lista está vacía, salimos.
            if (lista == null || lista.Count() == 0)
            {
                return;
            }

            using (OleDbConnection conexion = new OleDbConnection(App.Global.CadenaConexion))
            {
                //string SQLInsertar = "INSERT INTO Festivos (Año, Fecha) VALUES (?, ?)";
                string SQLInsertar = "InsertarFestivo";

                //string SQLActualizar = "UPDATE Festivos SET Año=?, Fecha=? WHERE Id=?";
                string SQLActualizar = "ActualizarFestivo";

                try {
                    conexion.Open();

                    foreach (Festivo festivo in lista)
                    {
                        if (festivo.Nuevo)
                        {
                            OleDbCommand comando = new OleDbCommand(SQLInsertar, conexion);
                            comando.CommandType = System.Data.CommandType.StoredProcedure;
                            Festivo.ParseToCommand(comando, festivo);
                            comando.ExecuteNonQuery();
                            festivo.Nuevo      = false;
                            festivo.Modificado = false;
                        }
                        else if (festivo.Modificado)
                        {
                            OleDbCommand comando = new OleDbCommand(SQLActualizar, conexion);
                            comando.CommandType = System.Data.CommandType.StoredProcedure;
                            Festivo.ParseToCommand(comando, festivo);
                            comando.ExecuteNonQuery();
                            festivo.Modificado = false;
                        }
                    }
                } catch (Exception ex) {
                    Utils.VerError("BdFestivos.GuardarFestivos", ex);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Guarda en la bd el objeto actual
        /// </summary>
        protected override bool SaveObject()
        {
            this.Datos.RaiseListChangedEvents = false;

            Festivo temp = _entity.Clone();

            temp.ApplyEdit();

            // do the save
            try
            {
                _entity = temp.Save();
                _entity.ApplyEdit();

                return(true);
            }
            finally
            {
                this.Datos.RaiseListChangedEvents = true;
            }
        }
コード例 #10
0
 protected override void GetFormSourceData(object[] parameters)
 {
     _entity = Festivo.New();
     _entity.BeginEdit();
 }
コード例 #11
0
 public FestivoUIForm(Festivo item, Form parent)
     : base(item.Oid, item, parent)
 {
     InitializeComponent();
 }
コード例 #12
0
ファイル: FestivosViewModel.cs プロジェクト: ander74/Orion
 public void Borrar(Festivo festivo)
 {
     _listaborrados.Add(festivo);
     ListaFestivos.Remove(festivo);
     HayCambios = true;
 }