Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Windows.Forms;
- namespace PlanillaFvh
- {
- public partial class WebFormaIngresoHorarios : System.Web.UI.Page
- {
- public Boolean EsEdicion = false;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack) return;
- LimpiarBloquearTextos();
- using (var fvhDb = new FvhContext.FvhDataContext())
- {
- MaestrosCombo.DataSource = fvhDb.Maestros;
- MaestrosCombo.DataTextField = @"Nombre";
- MaestrosCombo.DataValueField = @"IdMaestro";
- MaestrosCombo.DataBind();
- }
- }
- protected void MaestrosComboSelectedIndexChanged(object sender, EventArgs e)
- {
- using (var fvhDb = new FvhContext.FvhDataContext())
- {
- var listadosPorMaestro = from maestro in fvhDb.Maestros
- join asignacion in fvhDb.AsignacionRegimenMaestros on maestro.IdMaestro equals
- asignacion.IdMaestro
- where maestro.IdMaestro == Convert.ToInt32(MaestrosCombo.SelectedValue)
- join regimen in fvhDb.Regimens on asignacion.IdRegimen equals regimen.IdRegimen
- select new
- {
- asignacion.IdAsignacionRegimenMaestro,
- regimen.NombreRegimen,
- regimen.DiasDeRegimen,
- regimen.JornadasDeRegimen
- };
- //RegimenCombo.Items.Clear();
- RegimenCombo.DataSource = listadosPorMaestro;
- RegimenCombo.DataTextField = "NombreRegimen";
- RegimenCombo.DataValueField = "IdAsignacionRegimenMaestro";
- RegimenCombo.DataBind();
- }
- }
- public void LimpiarBloquearTextos()
- {
- LunesEn1.Text = "";
- LunesEn1.Enabled = false;
- LunesEn2.Text = "";
- LunesEn2.Enabled = false;
- LunesSa1.Text = "";
- LunesSa1.Enabled = false;
- LunesSa2.Text = "";
- LunesSa2.Enabled = false;
- MartesEn1.Text = "";
- MartesEn1.Enabled = false;
- MartesEn2.Text = "";
- MartesEn2.Enabled = false;
- MartesSa1.Text = "";
- MartesSa1.Enabled = false;
- MartesSa2.Text = "";
- MartesSa2.Enabled = false;
- MiercolesEn1.Text = "";
- MiercolesEn1.Enabled = false;
- MiercolesEn2.Text = "";
- MiercolesEn2.Enabled = false;
- MiercolesSa1.Text = "";
- MiercolesSa1.Enabled = false;
- MiercolesSa2.Text = "";
- MiercolesSa2.Enabled = false;
- JuevesEn1.Text = "";
- JuevesEn1.Enabled = false;
- JuevesEn2.Text = "";
- JuevesEn2.Enabled = false;
- JuevesSa1.Text = "";
- JuevesSa1.Enabled = false;
- JuevesSa2.Text = "";
- JuevesSa2.Enabled = false;
- ViernesEn1.Text = "";
- ViernesEn1.Enabled = false;
- ViernesEn2.Text = "";
- ViernesEn2.Enabled = false;
- ViernesSa1.Text = "";
- ViernesSa1.Enabled = false;
- ViernesSa2.Text = "";
- ViernesSa2.Enabled = false;
- SabadoEn1.Text = "";
- SabadoEn1.Enabled = false;
- SabadoEn2.Text = "";
- SabadoEn2.Enabled = false;
- SabadoSa1.Text = "";
- SabadoSa1.Enabled = false;
- SabadoSa2.Text = "";
- SabadoSa2.Enabled = false;
- GuardarBoton.Enabled = false;
- }
- public void HabilitarTextos()
- {
- LunesEn1.Enabled = true;
- LunesEn2.Enabled = true;
- LunesSa1.Enabled = true;
- LunesSa2.Enabled = true;
- MartesEn1.Enabled = true;
- MartesEn2.Enabled = true;
- MartesSa1.Enabled = true;
- MartesSa2.Enabled = true;
- MiercolesEn1.Enabled = true;
- MiercolesEn2.Enabled = true;
- MiercolesSa1.Enabled = true;
- MiercolesSa2.Enabled = true;
- JuevesEn1.Enabled = true;
- JuevesEn2.Enabled = true;
- JuevesSa1.Enabled = true;
- JuevesSa2.Enabled = true;
- ViernesEn1.Enabled = true;
- ViernesEn2.Enabled = true;
- ViernesSa1.Enabled = true;
- ViernesSa2.Enabled = true;
- SabadoEn1.Enabled = true;
- SabadoEn2.Enabled = true;
- SabadoSa1.Enabled = true;
- SabadoSa2.Enabled = true;
- }
- public void DeshabilitarTextos()
- {
- LunesEn1.Enabled = false;
- LunesEn2.Enabled = false;
- LunesSa1.Enabled = false;
- LunesSa2.Enabled = false;
- MartesEn1.Enabled = false;
- MartesEn2.Enabled = false;
- MartesSa1.Enabled = false;
- MartesSa2.Enabled = false;
- MiercolesEn1.Enabled = false;
- MiercolesEn2.Enabled = false;
- MiercolesSa1.Enabled = false;
- MiercolesSa2.Enabled = false;
- JuevesEn1.Enabled = false;
- JuevesEn2.Enabled = false;
- JuevesSa1.Enabled = false;
- JuevesSa2.Enabled = false;
- ViernesEn1.Enabled = false;
- ViernesEn2.Enabled = false;
- ViernesSa1.Enabled = false;
- ViernesSa2.Enabled = false;
- SabadoEn1.Enabled = false;
- SabadoEn2.Enabled = false;
- SabadoSa1.Enabled = false;
- SabadoSa2.Enabled = false;
- }
- protected void BuscarBotonClick(object sender, EventArgs e)
- {
- if (Page.IsValid)
- {
- var abuscar =Convert.ToInt32(RegimenCombo.SelectedValue);
- using (var fvhDb = new FvhContext.FvhDataContext())
- {
- var horarios = from horario in fvhDb.Horarios
- join asignacion in fvhDb.AsignacionRegimenMaestros on horario.IdAsignacionRegimenMaestro
- equals asignacion.IdAsignacionRegimenMaestro
- join dia in fvhDb.Dias on horario.IdDia equals dia.IdDia
- where asignacion.IdAsignacionRegimenMaestro == abuscar
- select new
- {
- horario.Entrada1,
- horario.Salida1,
- horario.Entrada2,
- horario.Salida2,
- dia.NombreDia
- };
- if (horarios.Count() > 0)
- {
- EsEdicion = true;
- LimpiarBloquearTextos();
- var formato = "{0:D2}:{1:D2}";
- foreach (var horario in horarios)
- {
- if (string.Compare(horario.NombreDia.ToUpper(), @"LUNES") == 0)
- {
- LunesEn1.Text = string.Format(formato,horario.Entrada1.Hour,horario.Entrada1.Minute);
- if (horario.Salida1.HasValue)
- LunesSa1.Text = string.Format(formato,horario.Salida1.Value.Hour,horario.Salida1.Value.Minute);
- if (horario.Entrada2.HasValue)
- LunesEn2.Text = string.Format(formato, horario.Entrada2.Value.Hour,
- horario.Entrada2.Value.Minute);
- LunesSa2.Text = string.Format(formato,horario.Salida2.Hour,horario.Salida2.Minute);
- }
- if (string.Compare(horario.NombreDia.ToUpper(), @"MARTES") == 0)
- {
- MartesEn1.Text = string.Format(formato,horario.Entrada1.Hour,horario.Entrada1.Minute);
- if (horario.Salida1.HasValue)
- MartesSa1.Text = string.Format(formato,horario.Salida1.Value.Hour,horario.Salida1.Value.Minute);
- if (horario.Entrada2.HasValue)
- MartesEn2.Text = string.Format(formato, horario.Entrada2.Value.Hour,
- horario.Entrada2.Value.Minute);
- MartesSa2.Text = string.Format(formato,horario.Salida2.Hour,horario.Salida2.Minute);
- }
- if (string.Compare(horario.NombreDia.ToUpper(), @"MIERCOLES") == 0)
- {
- MiercolesEn1.Text = string.Format(formato,horario.Entrada1.Hour,horario.Entrada1.Minute);
- if (horario.Salida1.HasValue)
- MiercolesSa1.Text = string.Format(formato,horario.Salida1.Value.Hour,horario.Salida1.Value.Minute);
- if (horario.Entrada2.HasValue)
- MiercolesEn2.Text = string.Format(formato,horario.Entrada2.Value.Hour,horario.Entrada2.Value.Minute);
- MiercolesSa2.Text = string.Format(formato,horario.Salida2.Hour,horario.Salida2.Minute);
- }
- if (string.Compare(horario.NombreDia.ToUpper(), @"JUEVES") == 0)
- {
- JuevesEn1.Text = string.Format(formato,horario.Entrada1.Hour,horario.Entrada1.Minute);
- if (horario.Salida1.HasValue)
- JuevesSa1.Text = string.Format(formato,horario.Salida1.Value.Hour,horario.Salida1.Value.Minute);
- if (horario.Entrada2.HasValue)
- JuevesEn2.Text = string.Format(formato, horario.Entrada2.Value.Hour,
- horario.Entrada2.Value.Minute);
- JuevesSa2.Text = string.Format(formato,horario.Salida2.Hour,horario.Salida2.Minute);
- }
- if (string.Compare(horario.NombreDia.ToUpper(), @"VIERNES") == 0)
- {
- ViernesEn1.Text = string.Format(formato,horario.Entrada1.Hour,horario.Entrada1.Minute);
- if (horario.Salida1.HasValue)
- ViernesSa1.Text = string.Format(formato,horario.Salida1.Value.Hour,horario.Salida1.Value.Minute);
- if (horario.Entrada2.HasValue)
- ViernesEn2.Text = string.Format(formato, horario.Entrada2.Value.Hour,
- horario.Entrada2.Value.Minute);
- ViernesSa2.Text = string.Format(formato,horario.Salida2.Hour,horario.Salida2.Minute);
- }
- if (string.Compare(horario.NombreDia.ToUpper(), @"SABADO") == 0)
- {
- SabadoEn1.Text = string.Format(formato,horario.Entrada1.Hour,horario.Entrada1.Minute);
- if (horario.Salida1.HasValue)
- SabadoSa1.Text = string.Format(formato,horario.Salida1.Value.Hour,horario.Salida1.Value.Minute);
- if (horario.Entrada2.HasValue)
- SabadoEn2.Text = string.Format(formato, horario.Entrada2.Value.Hour,
- horario.Entrada2.Value.Minute);
- SabadoSa2.Text = string.Format(formato,horario.Salida2.Hour,horario.Salida2.Minute);
- }
- }
- //aqui va el messagebox
- if(MessageBox.Show("Este horario ya existe, \n ¿desea editarlo?","Planilla Fvh",MessageBoxButtons.YesNo)==DialogResult.Yes)
- {
- GuardarBoton.Enabled = true;
- EsEdicion = true;
- HabilitarTextos();
- }
- }
- else
- {
- EsEdicion = false;
- GuardarBoton.Enabled = true;
- HabilitarTextos();
- }
- }
- }
- }
- protected void GuardarBotonClick(object sender, EventArgs e)
- {
- var nuevoHorario = new Validacion();
- nuevoHorario.IdAsignacionRegimenMaestro = Convert.ToInt32(RegimenCombo.SelectedValue);
- var validos = 0;
- if (!Page.IsValid) return;
- //dia lunes!
- nuevoHorario.IdDia = 1;
- nuevoHorario.TextEntrada1 = LunesEn1.Text;
- nuevoHorario.TextSalida1 = LunesSa1.Text;
- nuevoHorario.TextEntrada2 = LunesEn2.Text;
- nuevoHorario.TextSalida2 = LunesSa2.Text;
- if (EsEdicion)
- {
- validos = validos + nuevoHorario.EditarValidar();
- }
- else
- {
- validos = validos + nuevoHorario.InsertarValidar();
- }
- //dia martes!
- nuevoHorario.IdDia = 2;
- nuevoHorario.TextEntrada1 = MartesEn1.Text;
- nuevoHorario.TextSalida1 = MartesSa1.Text;
- nuevoHorario.TextEntrada2 = MartesEn2.Text;
- nuevoHorario.TextSalida2 = MartesSa2.Text;
- if (EsEdicion)
- {
- validos = validos + nuevoHorario.EditarValidar();
- }
- else
- {
- validos = validos + nuevoHorario.InsertarValidar();
- }
- //dia Miercoles!
- nuevoHorario.IdDia = 3;
- nuevoHorario.TextEntrada1 = MiercolesEn1.Text;
- nuevoHorario.TextSalida1 = MiercolesSa1.Text;
- nuevoHorario.TextEntrada2 = MiercolesEn2.Text;
- nuevoHorario.TextSalida2 = MiercolesSa2.Text;
- if (EsEdicion)
- {
- validos = validos + nuevoHorario.EditarValidar();
- }
- else
- {
- validos = validos + nuevoHorario.InsertarValidar();
- }
- //dia Jueves!
- nuevoHorario.IdDia = 4;
- nuevoHorario.TextEntrada1 = JuevesEn1.Text;
- nuevoHorario.TextSalida1 = JuevesSa1.Text;
- nuevoHorario.TextEntrada2 = JuevesEn2.Text;
- nuevoHorario.TextSalida2 = JuevesSa2.Text;
- if (EsEdicion)
- {
- validos = validos + nuevoHorario.EditarValidar();
- }
- else
- {
- validos = validos + nuevoHorario.InsertarValidar();
- }
- //dia Viernes!
- nuevoHorario.IdDia = 5;
- nuevoHorario.TextEntrada1 = ViernesEn1.Text;
- nuevoHorario.TextSalida1 = ViernesSa1.Text;
- nuevoHorario.TextEntrada2 = ViernesEn2.Text;
- nuevoHorario.TextSalida2 = ViernesSa2.Text;
- if (EsEdicion)
- {
- validos = validos + nuevoHorario.EditarValidar();
- }
- else
- {
- validos = validos + nuevoHorario.InsertarValidar();
- }
- //dia Sabado!
- nuevoHorario.IdDia = 2;
- nuevoHorario.TextEntrada1 = SabadoEn1.Text;
- nuevoHorario.TextSalida1 = SabadoSa1.Text;
- nuevoHorario.TextEntrada2 = SabadoEn2.Text;
- nuevoHorario.TextSalida2 = SabadoSa2.Text;
- if (EsEdicion)
- {
- validos = validos + nuevoHorario.EditarValidar();
- }
- else
- {
- validos = validos + nuevoHorario.InsertarValidar();
- }
- if (validos > 0)
- {
- MessageBox.Show("Se han ingresado correctamente " + validos.ToString() + " dias a su horario",
- "Sistema de Planilla");
- }
- else
- {
- MessageBox.Show("No se ha podido ingresar ningun horario", "Sistema de Planillas");
- }
- }
- protected void RegimenComboSelectedIndexChanged(object sender, EventArgs e)
- {
- using (var fvhDb = new FvhContext.FvhDataContext())
- {
- var listadosPorMaestro = from maestro in fvhDb.Maestros
- join asignacion in fvhDb.AsignacionRegimenMaestros on maestro.IdMaestro equals
- asignacion.IdMaestro
- where maestro.IdMaestro == Convert.ToInt32(MaestrosCombo.SelectedValue)
- join regimen in fvhDb.Regimens on asignacion.IdRegimen equals regimen.IdRegimen
- select new
- {
- asignacion.IdAsignacionRegimenMaestro,
- regimen.NombreRegimen,
- regimen.DiasDeRegimen,
- regimen.JornadasDeRegimen
- };
- RegimenCombo.DataSource = listadosPorMaestro;
- RegimenCombo.DataTextField = "NombreRegimen";
- RegimenCombo.DataValueField = "IdAsignacionRegimenMaestro";
- RegimenCombo.DataBind();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment