Esempio n. 1
0
 private void Guardar(bool NuevoRegistro, string ID, string Nombre, string Descrip, decimal monto, string IDColaboradorAux)
 {
     try
     {
         EM_Gastos Datos = new EM_Gastos
         {
             NuevoRegistro = NuevoRegistro,
             IDGastos      = ID,
             IDMotivo      = 0,
             IDSubMotivo   = 0,
             Nombre        = Nombre,
             Descripcion   = Descrip,
             Monto         = monto,
             IDResponsable = IDColaboradorAux,
             Conexion      = Comun.Conexion,
             IDUsuario     = User.Identity.Name
         };
         EM_GastosNegocio EN = new EM_GastosNegocio();
         EN.ACGastos(Datos);
         if (Datos.Completado)
         {
             Response.Redirect("frmGastosGrid.aspx", false);
         }
         else
         {
             string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error al guardar los datos.", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true);
             ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 public List <EM_Gastos> ObtenerGastos(EM_Gastos Datos)
 {
     try
     {
         List <EM_Gastos> Lista = new List <EM_Gastos>();
         EM_Gastos        Item;
         SqlDataReader    Dr = SqlHelper.ExecuteReader(Datos.Conexion, "EM_spCSLDB_get_Gastos");
         while (Dr.Read())
         {
             Item                   = new EM_Gastos();
             Item.IDGastos          = Dr.GetString(Dr.GetOrdinal("IDGastos"));
             Item.IDMotivo          = Dr.GetInt32(Dr.GetOrdinal("IDMotivo"));
             Item.IDSubMotivo       = Dr.GetInt32(Dr.GetOrdinal("IDSubMotivo"));
             Item.Nombre            = Dr.GetString(Dr.GetOrdinal("NombreGasto"));
             Item.Descripcion       = Dr.GetString(Dr.GetOrdinal("Descripcion"));
             Item.Monto             = Dr.GetDecimal(Dr.GetOrdinal("Monto"));
             Item.IDResponsable     = Dr.GetString(Dr.GetOrdinal("IDResponsable"));
             Item.NombreResponsable = Dr.GetString(Dr.GetOrdinal("NombreColaborador"));
             Lista.Add(Item);
         }
         return(Lista);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
 private void CargarDatos(EM_Gastos DatosAux)
 {
     try
     {
         hf.Value             = DatosAux.IDGastos.ToString();
         txtGastos.Value      = DatosAux.Nombre.ToString();
         txtDescripcion.Value = DatosAux.Descripcion.ToString();
         txtMonto.Value       = DatosAux.Monto.ToString();
         if (this.IDTipoUsuario == 1 || this.IDTipoUsuario == 3)
         {
             string ScriptError = @"
             $(document).ready(
                 function() {                        
                 document.getElementById('cmbEncargado').value='" + DatosAux.IDResponsable + @"';
             });";
             ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true);
         }
         else
         {
             hf2.Value = DatosAux.IDResponsable.ToString();
         }
         Response.Cookies.Clear();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 4
0
 public void EliminarGastosXID(EM_Gastos Datos)
 {
     try
     {
         EM_GastosDatos GD = new EM_GastosDatos();
         GD.EliminarGastosXID(Datos);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
 public void ObtenerDetalleGastosXID(EM_Gastos Datos)
 {
     try
     {
         EM_GastosDatos GD = new EM_GastosDatos();
         GD.ObtenerDetalleGastosXID(Datos);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
 public List <EM_Gastos> ObtenerGastos(EM_Gastos Datos)
 {
     try
     {
         EM_GastosDatos GD = new EM_GastosDatos();
         return(GD.ObtenerGastos(Datos));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 7
0
 public void ACGastos(EM_Gastos Datos)
 {
     try
     {
         EM_GastosDatos GD = new EM_GastosDatos();
         GD.ACGastos(Datos);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void CargarGridGastos()
 {
     try
     {
         EM_Gastos Datos = new EM_Gastos {
             Conexion = Comun.Conexion
         };
         EM_GastosNegocio GN = new EM_GastosNegocio();
         ListaGastos = GN.ObtenerGastos(Datos);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["op"] != null && Request.QueryString["op"] == "3")
                {
                    if (Request.QueryString["id"] != null)
                    {
                        string    AuxID = Request.QueryString["id"].ToString();
                        EM_Gastos Datos = new EM_Gastos {
                            Conexion = Comun.Conexion, IDGastos = AuxID, IDUsuario = Comun.IDUsuario
                        };
                        EM_GastosNegocio GN = new EM_GastosNegocio();
                        GN.EliminarGastosXID(Datos);
                        if (Datos.Completado)
                        {
                            string ScriptError = DialogMessage.Show(TipoMensaje.Success, "Registro eliminado correctamente.", "Información", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true);
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true);
                        }
                        else
                        {
                            string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error al guardar los datos.", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true);
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true);
                        }
                    }
                }
                if (!IsPostBack)
                {
                }
                else
                {
                }
                this.CargarGridGastos();

                if (Request.QueryString["errorMessage"] != null)
                {
                    string ScriptError = DialogMessage.Show(TipoMensaje.Error, "Error al cargar los datos. Intenté nuevamente", "Error", ShowMethod.FadeIn, HideMethod.FadeOut, ToastPosition.TopFullWidth, true);
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "popup", ScriptError, true);
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("PageError.aspx?errorNumber=" + ex.HResult);
            }
        }
Esempio n. 10
0
 public void EliminarGastosXID(EM_Gastos Datos)
 {
     try
     {
         object[] Parametros = { Datos.IDGastos, Datos.IDUsuario };
         object   Result     = SqlHelper.ExecuteScalar(Datos.Conexion, "EM_spCSLDB_del_Gastos", Parametros);
         int      Resultado  = 0;
         int.TryParse(Result.ToString(), out Resultado);
         if (Resultado == 1)
         {
             Datos.Completado = true;
         }
         Datos.Resultado = Resultado;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 11
0
 public void ACGastos(EM_Gastos Datos)
 {
     try
     {
         object[]      Parametros = { Datos.NuevoRegistro, Datos.IDGastos, Datos.IDMotivo, Datos.IDSubMotivo, Datos.Nombre, Datos.Descripcion, Datos.Monto, Datos.IDResponsable, Datos.IDUsuario };
         SqlDataReader Dr         = SqlHelper.ExecuteReader(Datos.Conexion, "EM_spCSLDB_AC_Gastos", Parametros);
         while (Dr.Read())
         {
             int Resultado = Dr.GetInt32(Dr.GetOrdinal("Resultado"));
             if (Resultado == 1)
             {
                 Datos.Completado = true;
                 Datos.IDGastos   = Dr.GetString(Dr.GetOrdinal("IDGastos"));
             }
             Datos.Resultado = Resultado;
             break;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 12
0
 public void ObtenerDetalleGastosXID(EM_Gastos Datos)
 {
     try
     {
         object[]      Parametros = { Datos.IDGastos };
         SqlDataReader Dr         = SqlHelper.ExecuteReader(Datos.Conexion, "EM_spCSLDB_get_GastosDetalleXID", Parametros);
         while (Dr.Read())
         {
             Datos.IDGastos      = Dr.GetString(Dr.GetOrdinal("IDGastos"));
             Datos.IDMotivo      = Dr.GetInt32(Dr.GetOrdinal("IDMotivo"));
             Datos.IDSubMotivo   = Dr.GetInt32(Dr.GetOrdinal("IDSubMotivo"));
             Datos.Nombre        = Dr.GetString(Dr.GetOrdinal("NombreGasto"));
             Datos.Descripcion   = Dr.GetString(Dr.GetOrdinal("Descripcion"));
             Datos.Monto         = Dr.GetDecimal(Dr.GetOrdinal("Monto"));
             Datos.IDResponsable = Dr.GetString(Dr.GetOrdinal("IDResponsable"));
             Datos.Completado    = true;
             break;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     InciarFormulario();
     if (!IsPostBack)
     {
         if (Request.QueryString["op"] != null)
         {
             if (Request.QueryString["op"] == "2")
             {
                 if (Request.QueryString["id"] != null)
                 {
                     string ID = Request.QueryString["id"].ToString();
                     if (Request.QueryString["id"].ToString() == ID)
                     {
                         //Obtener los datos y dibujarlos.
                         EM_Gastos DatosAux = new EM_Gastos {
                             Conexion = Comun.Conexion, IDGastos = ID
                         };
                         EM_GastosNegocio CN = new EM_GastosNegocio();
                         CN.ObtenerDetalleGastosXID(DatosAux);
                         if (DatosAux.Completado)
                         {
                             this.CargarDatos(DatosAux);
                         }
                         else
                         {
                             //Ocurrió un error
                             Response.Redirect("frmGastosGrid.aspx?error=" + "Error al cargar los datos&nError=1");
                         }
                     }
                     else
                     {
                         Response.Redirect("frmGastosGrid.aspx", false);
                     }
                 }
                 else
                 {
                     Response.Redirect("frmGastosGrid.aspx", false);
                 }
             }
             else
             {
                 Response.Redirect("frmGastosGrid.aspx", false);
             }
         }
         else
         {
             this.IniciarDatos();
         }
     }
     else
     {
         if (Request.Form.Count == 9)
         {
             string  txtNomb        = Request.Form["ctl00$cph_MasterBody$txtGastos"].ToString();
             string  txtDescripcion = Request.Form["ctl00$cph_MasterBody$txtDescripcion"].ToString();
             decimal Monto;
             decimal.TryParse(Request.Form["ctl00$cph_MasterBody$txtMonto"].ToString(), out Monto);
             string IDColaboradorAux = Request.Form["cmbEncargado"].ToString();
             string IDGastos         = "";
             try
             {
                 string AuxID = Request.Form["ctl00$cph_MasterBody$hf"].ToString();
                 IDGastos = AuxID;
                 bool NuevoRegistro = string.IsNullOrEmpty(IDGastos);
                 this.Guardar(NuevoRegistro, IDGastos, txtNomb, txtDescripcion, Monto, IDColaboradorAux);
             }
             catch (Exception ex)
             {
                 Response.Redirect("ErrorPage.aspx?msjError=" + ex.Message);
             }
         }
         else if (Request.Form.Count == 10)
         {
             string  txtNomb        = Request.Form["ctl00$cph_MasterBody$txtGastos"].ToString();
             string  txtDescripcion = Request.Form["ctl00$cph_MasterBody$txtDescripcion"].ToString();
             decimal Monto;
             decimal.TryParse(Request.Form["ctl00$cph_MasterBody$txtMonto"].ToString(), out Monto);
             string IDColaboradorAux = Request.Form["ctl00$cph_MasterBody$hf2"].ToString();
             string Vacio            = Request.Form["ctl00$cph_MasterBody$hf3"].ToString();
             string IDGastos         = "";
             try
             {
                 string AuxID = Request.Form["ctl00$cph_MasterBody$hf"].ToString();
                 IDGastos = AuxID;
                 bool NuevoRegistro = string.IsNullOrEmpty(IDGastos);
                 this.Guardar(NuevoRegistro, IDGastos, txtNomb, txtDescripcion, Monto, IDColaboradorAux);
             }
             catch (Exception ex)
             {
                 Response.Redirect("ErrorPage.aspx?msjError=" + ex.Message);
             }
         }
     }
 }