Example #1
0
        protected void BtnGuardarSalida_Click(object sender, EventArgs e)
        {
            try{
                validacionesSalida();
                String    vQuery = "";
                DataTable vInfo  = new DataTable();
                DataTable vAprob = (DataTable)Session["SEC_APROBACION_SALIDA"];

                if (Session["ID_ENTRADA"] != null)
                {
                    String vId = Session["ID_ENTRADA"].ToString();
                    vQuery = "[RSP_Seguridad] 10," + vId +
                             ",'" + TxNombreSalida.Text + "'" +
                             "," + DDLMotivoSalida.SelectedValue +
                             ",'" + TxObservacionesSalida.Text + "'" +
                             "," + vAprob.Rows[0]["id"].ToString();

                    vInfo = vConexion.obtenerDataTable(vQuery);
                    if (vInfo.Rows.Count > 0)
                    {
                        if (vAprob != null)
                        {
                            String vIdAprob = vAprob.Rows[0]["id"].ToString();
                            vQuery = "[RSP_Seguridad] 20," + vIdAprob;
                            vConexion.ejecutarSql(vQuery);
                        }

                        cargarDatos();
                        UpdateDivBusquedas.Update();
                        Mensaje("Salida guardada con éxito", WarningType.Success);
                    }
                    else
                    {
                        Mensaje("Hubo un error al guardar la salida.", WarningType.Danger);
                    }
                }
                else
                {
                    String vRSP = DDLMotivoSalida.SelectedValue == "9" ? "[RSP_Seguridad] 13" : "[RSP_Seguridad] 2";

                    vQuery = vRSP +
                             ",'" + TxNombreSalida.Text + "'" +
                             "," + DDLArticuloSalida.SelectedValue +
                             ",'" + TxSerieSalida.Text + "'" +
                             ",'" + TxInventarioSalida.Text + "'" +
                             "," + DDLMotivoSalida.SelectedValue +
                             ",'" + TxObservacionesSalida.Text + "'" +
                             ",'" + Session["USUARIO"].ToString() + "'";
                    vInfo = vConexion.obtenerDataTable(vQuery);
                    if (vInfo.Rows.Count > 0)
                    {
                        if (vAprob != null)
                        {
                            String vIdAprob = vAprob.Rows[0]["id"].ToString();
                            vQuery = "[RSP_Seguridad] 20," + vIdAprob;
                            vConexion.ejecutarSql(vQuery);
                        }//else
                         //enviaCorreo(vInfo);

                        cargarDatos();
                        UpdateDivBusquedas.Update();
                        Mensaje("Salida guardada con éxito", WarningType.Success);
                    }
                    else
                    {
                        Mensaje("Hubo un error al guardar la entrada.", WarningType.Danger);
                    }
                }

                limpiarFormulario();
                TxBusquedaSalida.Focus();
            }catch (Exception Ex) {
                Mensaje(Ex.Message, WarningType.Danger);
            }
        }
Example #2
0
        protected void TxBusquedaSalida_TextChanged(object sender, EventArgs e)
        {
            try{
                if (TxBusquedaSalida.Text != "" || TxBusquedaSalida.Text != string.Empty)
                {
                    String    vQuery        = "[RSP_Seguridad] 16,'" + TxBusquedaSalida.Text + "'";
                    DataTable vVerificacion = vConexion.obtenerDataTable(vQuery);
                    if (vVerificacion.Rows.Count > 0)
                    {
                        TxBusquedaSalida.Focus();
                        limpiarFormularioSalida();
                        Mensaje("El número de serie tiene una entrada pendiente. Favor ingrese otro.", WarningType.Warning);
                    }
                    else
                    {
                        vQuery = "[RSP_Seguridad] 21,'" + TxBusquedaSalida.Text + "'";
                        DataTable vDatos1 = vConexion.obtenerDataTable(vQuery);
                        if (vDatos1.Rows.Count > 0)
                        {
                            LbAprobacion.Text = "Aprobado!";
                            LbAprobacion.Attributes.CssStyle.Value = "color:Green; margin-top:100px; margin-left:20px;";
                            Session["SEC_APROBACION_SALIDA"]       = vDatos1;
                        }
                        else
                        {
                            LbAprobacion.Text = "No Aprobado!";
                            LbAprobacion.Attributes.CssStyle.Value = "color:Tomato; margin-bottom:10px; margin-left:20px;";
                        }
                        LbAprobacion.Visible = true;

                        vQuery = "[RSP_Seguridad] 6,'" + TxBusquedaSalida.Text + "'";
                        DataTable vDatos = vConexion.obtenerDataTable(vQuery);
                        if (vDatos.Rows.Count > 0)
                        {
                            Session["ID_ENTRADA"] = vDatos.Rows[0]["id"].ToString();

                            DivEntradas.Visible      = true;
                            LbIdEntrada.Text         = vDatos.Rows[0]["id"].ToString();
                            LbNombreEntrada.Text     = vDatos.Rows[0]["nombre"].ToString();
                            LbArticuloEntrada.Text   = vDatos.Rows[0]["articulo"].ToString();
                            LbSerieEntrada.Text      = vDatos.Rows[0]["serie"].ToString();
                            LbInventarioEntrada.Text = vDatos.Rows[0]["inventario"].ToString();
                            LbFechaEntrada.Text      = vDatos.Rows[0]["fechaEntrada"].ToString();

                            TxInventarioSalida.Text         = vDatos.Rows[0]["inventario"].ToString();
                            DDLArticuloSalida.SelectedValue = vDatos.Rows[0]["idArticulo"].ToString();

                            DivBodySalida.Visible   = true;
                            LbMensajeSalida.Text    = "";
                            LbMensajeSalida.Visible = false;
                            UpdatePanel7.Update();
                        }
                        else
                        {
                            TxInventarioSalida.Text         = string.Empty;
                            DDLArticuloSalida.SelectedIndex = -1;
                            Session["ID_ENTRADA"]           = null;
                            DivEntradas.Visible             = false;
                            DivBodySalida.Visible           = false;
                            LbMensajeSalida.Visible         = true;
                            LbMensajeSalida.Text            = LbAprobacion.Text == "Aprobado!" ? "Cree un nuevo registro." : string.Empty;
                            UpdatePanel7.Update();
                        }
                        TxNombreSalida.Focus();
                        TxSerieSalida.Text = TxBusquedaSalida.Text;
                    }
                    UpdatePanel8.Update();
                }
                else
                {
                    limpiarFormulario();
                }
            }catch (Exception ex) {
                Mensaje(ex.Message, WarningType.Danger);
            }
        }