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;
     }
 }
 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. 4
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);
             }
         }
     }
 }