using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Extensiones; using System.Data; public partial class RH_CatChecadores : ClsPaginas { private int CveChecador { get { return ViewState["CveChecador"].ToString().ToEntero(); } set { ViewState["CveChecador"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CargaSubProyectos(); CargaDatos(); } } private void CargaDatos() { ClsRH ObjRH = new ClsRH(); if (ObjRH.GetChecadores(-1, UsuarioActual.CveEmpresa)) { GvDatos.DataSource = ObjRH.DtResultados; } ObjRH.Dispose(); GvDatos.DataBind(); GvDatos.HeaderRow.Cells[1].Text = LblSubProyecto.Text; } private void CargaSubProyectos() { DdlSubProyecto.DataSource = get_GlobalDTSubProyectos(-1, CveEmpresa: UsuarioActual.CveEmpresa); DdlSubProyecto.DataBind(); CargarCentrosDeCosto(null, DdlSubProyecto,null, LblSubProyecto); } protected void BtnAgregarChecador_Click(object sender, EventArgs e) { TxtChecador.Text = ""; DdlSubProyecto.SelectedValue = "-1"; DdlModelo.SelectedValue = "-1"; TxtIPLocal.Text = ""; TxtPuerto.Text = ""; BtnChecadorAgregar.Text = "Agregar"; divChkEstatus.Visible = false; UpModalTiposD.Update(); RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); } protected void BtnChecadorAgregar_Click(object sender, EventArgs e) { ClsRH ObjRH = new ClsRH(); if (BtnChecadorAgregar.Text == "Agregar") { if (ObjRH.AddChecadores(TxtChecador.Text, DdlSubProyecto.SelectedValue.ToEntero(), TxtIPLocal.Text, TxtPuerto.Text, UsuarioActual.CveUsuario,CveModelo:DdlModelo.SelectedValue.ToEntero())) { Alert("Checador agregado correctamente"); } } else { if (ObjRH.UpdateChecadores(CveChecador,TxtChecador.Text,DdlSubProyecto.SelectedValue.ToEntero(),TxtIPLocal.Text,TxtPuerto.Text,Estatus: ChkEstatus.Checked, CveModelo: DdlModelo.SelectedValue.ToEntero())) { Alert("Checador actualizado correctamente"); } } ObjRH.Dispose(); CargaDatos(); UpDatos.Update(); RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarTiposD")); } protected void LnkEditar_Click(object sender, EventArgs e) { GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); CveChecador = GvRow.DataKey("CveChecador").ToEntero(); TxtChecador.Text = GvRow.DataKey("Checador"); DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto")); DdlModelo.SelectedValue = GvRow.DataKey("CveModelo"); TxtIPLocal.Text = GvRow.DataKey("IPLocal"); TxtPuerto.Text = GvRow.DataKey("Puerto"); BtnChecadorAgregar.Text = "Actualizar"; ChkEstatus.Checked = GvRow.DataKey("Estatus") == "Activo"; divChkEstatus.Visible = true; UpModalTiposD.Update(); RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD")); } protected void LnkEliminar_Click(object sender, EventArgs e) { GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer); ClsRH ObjRH = new ClsRH(); if (ObjRH.RemoveChecadores(GvRow.DataKey("CveChecador").ToEntero())) { Alert("Checador eliminado correctamente"); CargaDatos(); UpDatos.Update(); } ObjRH.Dispose(); } protected void GvChecadorSubProyectos_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { e.Row.FCCheckBox("Chk").Checked = e.Row.DataKey("CveChecador").ToEntero() > 0 ? true : false; } } }