protected void grdRecibos_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }

            try
            {
                if (e.CommandName == "Editar")
                {
                    gsEgresosVarios_BuscarDetalleResult objEVDetalle = JsonHelper.JsonDeserialize <List <gsEgresosVarios_BuscarDetalleResult> >((string)ViewState["lstEVDetalle"]).Find(x => x.ID_Amarre.ToString() == e.CommandArgument.ToString());
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "ShowInsertForm(" + JsonHelper.JsonSerializer(objEVDetalle) + ");", true);
                }
            }
            catch (Exception ex) {
                lblMensaje.Text     = ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }

            if (!ConnectionHelpers.CheckForInternetConnection())
            {
                throw new ArgumentException("ERROR: Revisar su conexión a internet.");
            }

            AutoCompleteBoxEntry entry;

            try {
                if (!Page.IsPostBack)
                {
                    LoginWCF.LoginWCFClient objLoginWCF = new LoginWCF.LoginWCFClient();
                    objLoginWCF.AuditoriaMenu_Registrar(System.Web.HttpContext.Current.Request.Url.AbsolutePath, Environment.MachineName,
                                                        ((Usuario_LoginResult)System.Web.HttpContext.Current.Session["Usuario"]).idUsuario);

                    dpFecEmision.SelectedDate = DateTime.Now;
                    txtIGV.Value      = 0;
                    txtImpBase.Value  = 0;
                    txtInafecto.Value = 0;
                    txtImporte.Value  = 0;
                    TipoGasto_Cargar();
                    Documento_ListarTipoCompra();
                    if (Request.QueryString["objRecibo"] != "0")
                    {
                        Title = "Modificar documnento";

                        gsEgresosVarios_BuscarDetalleResult objEVDetalle = JsonHelper.JsonDeserialize <gsEgresosVarios_BuscarDetalleResult>(Request.QueryString["objRecibo"]);

                        txtComentario.Text = objEVDetalle.Observaciones;

                        if (!string.IsNullOrEmpty(objEVDetalle.ID_Agenda))
                        {
                            entry      = new AutoCompleteBoxEntry();
                            entry.Text = objEVDetalle.ID_Agenda + "-" + objEVDetalle.Agenda;
                            acbProveedor.Entries.Add(entry);
                        }

                        if (!string.IsNullOrEmpty(objEVDetalle.ID_Item))
                        {
                            cboTipoGasto.SelectedValue = objEVDetalle.ID_Item;
                        }

                        if (!string.IsNullOrEmpty(objEVDetalle.ID_Documento.ToString()))
                        {
                            //entry = new AutoCompleteBoxEntry();
                            //entry.Text = objEVDetalle.ID_Documento + "-" + objEVDetalle.NombreDocumento;
                            //acbTipoDocumento.Entries.Add(entry);
                            cboTipoDocumento.SelectedValue = objEVDetalle.ID_Documento.ToString();
                        }

                        txtSerie.Text     = objEVDetalle.Serie;
                        txtNumero.Text    = objEVDetalle.Numero.ToString();
                        txtImporte.Value  = (double)objEVDetalle.Importe;
                        txtIGV.Value      = (double)objEVDetalle.ImporteIGV;
                        txtImpBase.Value  = (double)objEVDetalle.ImporteBaseIGV;
                        txtInafecto.Value = (double)objEVDetalle.ImporteInafecto;
                        if (objEVDetalle.FechaEmision != null)
                        {
                            dpFecEmision.SelectedDate = objEVDetalle.FechaEmision;
                        }

                        lblMensaje.Text = "Datos del gasto " + objEVDetalle.ID_Amarre.ToString() + " cargados con éxito";
                    }
                    else
                    {
                        Title           = "Registrar documento";
                        lblMensaje.Text = "Datos iniciales cargados con éxito";
                    }

                    lblMensaje.CssClass = "mensajeExito";
                }
            }
            catch (Exception ex) {
                lblMensaje.Text     = "ERROR: " + ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
示例#3
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }

            gsEgresosVarios_BuscarDetalleResult objEVDetalle;

            //string idAgenda = "";
            try {
                //if (!btnAgregar.Visible) {
                //    AgendaWCFClient objAgendaWCF = new AgendaWCFClient();
                //    if (txtNroRUC.Text.Length != 11)
                //        throw new ArgumentException("El número RUC ingresado no es correcto");
                //    if (string.IsNullOrEmpty(txtRazonSocial.Text))
                //        throw new ArgumentException("Se debe ingresar la razón social del proveedor.");
                //    idAgenda = objAgendaWCF.Agenda_RegistrarProveedor(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                //                ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, txtNroRUC.Text, txtRazonSocial.Text.ToUpper());
                //}

                objEVDetalle = new gsEgresosVarios_BuscarDetalleResult();
                if (Request.QueryString["objRecibo"] != "0")
                {
                    objEVDetalle      = JsonHelper.JsonDeserialize <gsEgresosVarios_BuscarDetalleResult>(Request.QueryString["objRecibo"]);
                    objEVDetalle.Tipo = "M";
                }
                else
                {
                    objEVDetalle      = new gsEgresosVarios_BuscarDetalleResult();
                    objEVDetalle.Tipo = "R";
                }


                if (string.IsNullOrEmpty(txtImporte.Text) || txtImporte.Value <= 0)
                {
                    throw new ArgumentException("Se debe ingresar un importe mayor 0 soles.");
                }
                objEVDetalle.Importe = (decimal)txtImporte.Value;
                if (cboTipoGasto.SelectedIndex < 0)
                {
                    throw new ArgumentException("Se debe seleccionar un tipo de gasto valido.");
                }
                objEVDetalle.ID_Item = cboTipoGasto.SelectedValue;
                objEVDetalle.Item    = cboTipoGasto.Text;
                //if (acbTipoDocumento.Entries.Count <= 0)
                //    throw new ArgumentException("Se debe ingresar un tipo de documento valido.");
                objEVDetalle.ID_Documento    = decimal.Parse(cboTipoDocumento.SelectedValue);
                objEVDetalle.NombreDocumento = cboTipoDocumento.SelectedItem.Text;
                if (acbProveedor.Entries.Count <= 0 || !acbProveedor.Text.Contains("-"))
                {
                    throw new ArgumentException("Se debe ingresar un proveedor valido.");
                }
                objEVDetalle.ID_Agenda = acbProveedor.Text.Split('-')[0];
                objEVDetalle.Agenda    = acbProveedor.Text.Split('-')[1];


                if (string.IsNullOrEmpty(txtSerie.Text))
                {
                    throw new ArgumentException("Se debe ingresar una serie valida.");
                }
                if (string.IsNullOrEmpty(txtNumero.Text))
                {
                    throw new ArgumentException("Se debe ingresar un número valido.");
                }

                if (txtNumero.Text == string.Empty)
                {
                    throw new ArgumentException("Se debe ingresar un número valido.");
                }
                else
                {
                    if (txtSerie.Text == string.Empty)
                    {
                        throw new ArgumentException("Se debe ingresar una serie valida.");
                    }
                    else
                    {
                        objEVDetalle.Serie           = txtSerie.Text.PadLeft(4, '0');
                        objEVDetalle.Numero          = (decimal)txtNumero.Value;
                        objEVDetalle.Observaciones   = txtComentario.Text;
                        objEVDetalle.FechaEmision    = dpFecEmision.SelectedDate.Value;
                        objEVDetalle.ImporteBaseIGV  = Convert.ToDecimal(txtImpBase.Value);
                        objEVDetalle.ImporteIGV      = Convert.ToDecimal(txtIGV.Value);
                        objEVDetalle.ImporteInafecto = Convert.ToDecimal(txtInafecto.Value);
                        objEVDetalle.Estado          = 1;
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CloseAndRebind(" + JsonHelper.JsonSerializer(objEVDetalle) + ");", true);
                    }
                }
            }
            catch (Exception ex) {
                lblMensaje.Text     = "ERROR: " + ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
        protected void ramGastosMng_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }

            if (!ConnectionHelpers.CheckForInternetConnection())
            {
                throw new ArgumentException("ERROR: Revisar su conexión a internet.");
            }

            try
            {
                if (e.Argument == "Rebind")
                {
                    //grdItem.MasterTableView.SortExpressions.Clear();
                    //grdItem.MasterTableView.GroupByExpressions.Clear();
                    //grdItem.DataSource = (List<gsItem_BuscarResult>)Session["lstProductos"];
                    //grdItem.DataBind();
                    ////Calcular_Glosa();

                    //lblMensaje.Text = "Se agregó el producto al pedido.";
                    //lblMensaje.CssClass = "mensajeExito";

                    //acbProducto.Entries.Clear();
                    //acbProducto.Focus();
                }

                if (e.Argument.Split('(')[0].Trim() == "RebindAndNavigate")
                {
                    grdRecibos.MasterTableView.SortExpressions.Clear();
                    grdRecibos.MasterTableView.GroupByExpressions.Clear();
                    List <gsEgresosVarios_BuscarDetalleResult> lst = JsonHelper.JsonDeserialize <List <gsEgresosVarios_BuscarDetalleResult> >((string)ViewState["lstEVDetalle"]);
                    string strEVDetalle = "{" + e.Argument.Split('{')[1];
                    gsEgresosVarios_BuscarDetalleResult objEVDetalle = JsonHelper.JsonDeserialize <gsEgresosVarios_BuscarDetalleResult>(strEVDetalle.Substring(0, strEVDetalle.Length - 1));
                    if (objEVDetalle.ID_Amarre == 0)
                    {
                        objEVDetalle.ID_Amarre = (lst.FindAll(x => x.ID_Amarre <= 0).Count + 1) * -1;
                    }
                    lst.Remove(lst.Find(x => x.ID_Amarre == objEVDetalle.ID_Amarre));
                    lst.Add(objEVDetalle);

                    lblTotal.Text = "Total: " + lst.ToList().AsEnumerable().Sum(x => x.Importe).ToString();

                    grdRecibos.DataSource = lst.OrderBy(x => x.ID_Amarre);
                    grdRecibos.DataBind();

                    ViewState["lstEVDetalle"] = JsonHelper.JsonSerializer(lst);
                    if (objEVDetalle.ID_Amarre > 0)
                    {
                        lblMensaje.Text = "Se modificó el gastos con código " + objEVDetalle.ID_Amarre.ToString();
                    }
                    else
                    {
                        lblMensaje.Text = "Se registró el gastos con código " + objEVDetalle.ID_Amarre.ToString();
                    }
                    lblMensaje.CssClass = "mensajeExito";
                }
            }
            catch (Exception ex) {
                lblMensaje.Text     = ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }