Пример #1
0
        private void cmbproducto_SelectedIndexChanged(object sender, EventArgs e)
        {
            DateTime FechaVen;

            errorProvider1.SetError(this.cmbProducto, string.Empty);
            try
            {
                SqlDataAdapter da1 = new SqlDataAdapter("Select Producto.* from Producto where Producto='" + cmbProducto.Text + "'", varpublic.conexion);
                DataTable      dt1 = new DataTable();
                da1.Fill(dt1);
                idProducto             = Convert.ToInt32(dt1.Rows[0]["IdProducto"]);
                PrecioUnitario         = Math.Round(Convert.ToDecimal(dt1.Rows[0]["UltPrecioVenta"]), 2);
                lblPrecioUnitario.Text = Convert.ToString(PrecioUnitario);
                StockMinimo            = Convert.ToDouble(dt1.Rows[0]["StockMinimo"]);
                StockActual            = Convert.ToDouble(dt1.Rows[0]["Stock"]);
                lblStockActual.Text    = Convert.ToString(StockActual);
                da1.Dispose();

                SqlDataAdapter da = new SqlDataAdapter("SELECT Top 1 DetalleEntrada.* FROM  DetalleEntrada  where  IdProducto = '" + idProducto + "' order by IdEntrada desc", varpublic.conexion);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                FechaVen          = Convert.ToDateTime(dt.Rows[0]["FechaVencimiento"]);
                lblFechaVcto.Text = Convert.ToString(FechaVen.ToShortDateString());;
                da.Dispose();
            }
            catch { }
        }
Пример #2
0
        public static List <Alerta> AlertaVerde(DateTime pFechaVmes, DateTime pFechaVquincena, DateTime pFechaVsemana, DateTime pFechaV2meses, DateTime pFechaV3meses, DateTime pFechaV6meses, DateTime pFechaVaño)
        {
            try
            {
                pFechaVmes      = pFechaVmes.AddDays(3);
                pFechaVquincena = pFechaVquincena.AddDays(3);
                pFechaVsemana   = pFechaVsemana.AddDays(3);
                pFechaV2meses   = pFechaV2meses.AddDays(3);
                pFechaV3meses   = pFechaV3meses.AddDays(3);
                pFechaV6meses   = pFechaV6meses.AddDays(3);
                pFechaVaño      = pFechaVaño.AddDays(3);
                List <Alerta> Verde      = new List <Alerta>();
                Conexion      conectar   = new Conexion();
                string        comando    = "SELECT NOMBRE,APELLIDO,NINGRESOS.FECHA_INICIO,INGRESOS.TIPO_INGRE FROM CLIENTES INNER JOIN  (select max(FECHA_INICIO)AS FECHA_INICIO,DOC_CLIENTE from INGRESOS group by DOC_CLIENTE) AS NINGRESOS  ON NINGRESOS.DOC_CLIENTE = CLIENTES.ID_CLIENTE INNER JOIN INGRESOS ON NINGRESOS.DOC_CLIENTE = INGRESOS.DOC_CLIENTE AND NINGRESOS.FECHA_INICIO=INGRESOS.FECHA_INICIO WHERE((NINGRESOS.FECHA_INICIO > @FECHA_V_MES AND NINGRESOS.FECHA_INICIO <=@FECHA_V_MES2 )AND(TIPO_INGRE = 'Mensual                  '))or((NINGRESOS.FECHA_INICIO > @FECHA_V_QUIN AND NINGRESOS.FECHA_INICIO <= @FECHA_V_QUIN2 )AND(TIPO_INGRE = 'Quincenal                '))or((NINGRESOS.FECHA_INICIO > @FECHA_V_SEMANA AND NINGRESOS.FECHA_INICIO <= @FECHA_V_SEMANA2 )AND(TIPO_INGRE = 'semanal                  '))or((NINGRESOS.FECHA_INICIO > @FECHA_V_2MESES AND NINGRESOS.FECHA_INICIO <= @FECHA_V_2MESES2 )AND(TIPO_INGRE = '2 Meses                  '))or((NINGRESOS.FECHA_INICIO > @FECHA_V_3MESES AND NINGRESOS.FECHA_INICIO <= @FECHA_V_3MESES2 )AND(TIPO_INGRE = '3 Meses                  '))or((NINGRESOS.FECHA_INICIO > @FECHA_V_6MESES AND NINGRESOS.FECHA_INICIO <= @FECHA_V_6MESES2 )AND(TIPO_INGRE = '6 Meses                  '))or((NINGRESOS.FECHA_INICIO > @FECHA_V_AÑO AND NINGRESOS.FECHA_INICIO <= @FECHA_V_AÑO2 )AND(TIPO_INGRE = 'Anual                    '))";
                DateTime      FechaVmes2 = pFechaVmes.AddDays(4);
                Console.WriteLine(Convert.ToString(pFechaVmes));
                Console.WriteLine(Convert.ToString(FechaVmes2));
                DateTime FechaVquincena2 = pFechaVquincena.AddDays(4);
                DateTime FechaVSemana2   = pFechaVsemana.AddDays(4);
                DateTime FechaV2meses2   = pFechaV2meses.AddDays(4);
                DateTime FechaV3meses2   = pFechaV3meses.AddDays(4);
                DateTime FechaV6meses2   = pFechaV6meses.AddDays(4);
                DateTime FechaVaño2      = pFechaVaño.AddDays(4);
                conectar.Abrir();
                SqlCommand cmd = new SqlCommand(comando, conectar.Conectarbd);
                cmd.Parameters.AddWithValue("@FECHA_V_MES", pFechaVmes);
                cmd.Parameters.AddWithValue("@FECHA_V_MES2", FechaVmes2);
                cmd.Parameters.AddWithValue("@FECHA_V_SEMANA", pFechaVsemana);
                cmd.Parameters.AddWithValue("@FECHA_V_SEMANA2", FechaVSemana2);
                cmd.Parameters.AddWithValue("@FECHA_V_QUIN", pFechaVquincena);
                cmd.Parameters.AddWithValue("@FECHA_V_QUIN2", FechaVquincena2);
                cmd.Parameters.AddWithValue("@FECHA_V_2MESES", pFechaV2meses);
                cmd.Parameters.AddWithValue("@FECHA_V_2MESES2", FechaV2meses2);
                cmd.Parameters.AddWithValue("@FECHA_V_3MESES", pFechaV3meses);
                cmd.Parameters.AddWithValue("@FECHA_V_3MESES2", FechaV3meses2);
                cmd.Parameters.AddWithValue("@FECHA_V_6MESES", pFechaV6meses);
                cmd.Parameters.AddWithValue("@FECHA_V_6MESES2", FechaV6meses2);
                cmd.Parameters.AddWithValue("@FECHA_V_AÑO", pFechaVaño);
                cmd.Parameters.AddWithValue("@FECHA_V_AÑO2", FechaVaño2);

                SqlDataReader read = cmd.ExecuteReader();
                while (read.Read())
                {
                    Alerta pAlerta = new Alerta();
                    pAlerta.Nombre   = read["NOMBRE"].ToString();
                    pAlerta.Apellido = read["APELLIDO"].ToString();
                    DateTime FechaIni = Convert.ToDateTime(read["FECHA_INICIO"].ToString());
                    DateTime FechaVen;
                    string   TipoPago = read["TIPO_INGRE"].ToString();
                    switch (TipoPago)
                    {
                    case "Mensual                  ":
                        FechaVen = FechaIni.AddMonths(1);
                        break;

                    case "Semanal                  ":
                        FechaVen = FechaIni.AddDays(7);
                        break;

                    case "Quincenal                ":
                        FechaVen = FechaIni.AddDays(15);
                        break;

                    case "2 Meses                  ":
                        FechaVen = FechaIni.AddMonths(2);
                        break;

                    case "3 Meses                  ":
                        FechaVen = FechaIni.AddMonths(3);
                        break;

                    case "6 Meses                  ":
                        FechaVen = FechaIni.AddMonths(6);
                        break;

                    case "Anual                    ":
                        FechaVen = FechaIni.AddYears(1);
                        break;

                    default:
                        FechaVen = FechaIni;
                        break;
                    }
                    pAlerta.Fecha_Vencimiento = FechaVen.ToString("dd-MM-yyyy");
                    pAlerta.Tipo_Pago         = TipoPago;
                    Verde.Add(pAlerta);
                }

                conectar.Cerrar();
                return(Verde);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(null);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Conexion Conectar = new Conexion();
                Conectar.Abrir();
                string comando = "SELECT * FROM CLIENTES WHERE ID_CLIENTE=@DOC";


                SqlCommand cmd = new SqlCommand(comando, Conectar.Conectarbd);
                cmd.Parameters.AddWithValue("@DOC", Convert.ToInt64(NroDocumento.Text));
                SqlDataReader read = cmd.ExecuteReader();
                while (read.Read())
                {
                    string Nombre    = read["NOMBRE"].ToString();
                    string Apellido  = read["APELLIDO"].ToString();
                    string Telefono  = read["TELEFONO"].ToString();
                    string Direccion = read["DIRECCION"].ToString();
                    string Genero    = read["GENERO"].ToString();
                    string TipoDoc   = read["DOC_CLIENTE"].ToString();
                    string Estatura  = read["ESTATURA_IN"].ToString();
                    textNombre.Text    = Nombre;
                    textApellido.Text  = Apellido;
                    textDireccion.Text = Direccion;
                    textTelefono.Text  = Telefono;
                    textGenero.Text    = Genero;
                    textTipoDoc.Text   = TipoDoc;
                    textEstatura.Text  = Estatura;
                }
                Conectar.Cerrar();
                string   FechaHoy = DateTime.Now.ToString("yyyy-MM-dd");
                DateTime FechaH   = Convert.ToDateTime(FechaHoy);
                string   comando2 = "SELECT * FROM INGRESOS WHERE FECHA_INGRE = (SELECT MAX(FECHA_INGRE) FROM INGRESOS WHERE DOC_CLIENTE = @DOC) AND DOC_CLIENTE = @DOC";
                Conectar.Abrir();
                SqlCommand cmd2 = new SqlCommand(comando2, Conectar.Conectarbd);
                cmd2.Parameters.AddWithValue("@DOC", Convert.ToInt64(NroDocumento.Text));
                SqlDataReader LFecha = cmd2.ExecuteReader();
                while (LFecha.Read())
                {
                    string FechaUlt   = LFecha["FECHA_INICIO"].ToString();
                    string FechaUlti2 = LFecha["FECHA_INGRE"].ToString();
                    string TipoPago   = LFecha["TIPO_INGRE"].ToString();
                    //textUlyimoPago.Text = LFecha["FECHA_INGRE"].ToString();
                    DateTime fecha = Convert.ToDateTime(FechaUlt);
                    textTipoPago.Text   = TipoPago;
                    textUlyimoPago.Text = FechaUlti2;
                    DateTime FechaVen;
                    Console.WriteLine(TipoPago);
                    if (TipoPago == "Mensual                  ")
                    {
                        FechaVen = fecha.AddMonths(1);
                        TOTAL    = 1;
                    }
                    else
                    {
                        if (TipoPago == "Quincenal                ")
                        {
                            FechaVen = fecha.AddDays(15);
                            TOTAL    = 2;
                        }
                        else
                        {
                            if (TipoPago == "Semanal                  ")
                            {
                                FechaVen = fecha.AddDays(7);
                                TOTAL    = 3;
                            }
                            else
                            {
                                if (TipoPago == "Diario                   ")
                                {
                                    FechaVen = fecha.AddDays(1);
                                    TOTAL    = 4;
                                }
                                else
                                {
                                    if (TipoPago == "2 Meses                  ")
                                    {
                                        FechaVen = fecha.AddMonths(2);
                                        TOTAL    = 5;
                                    }
                                    else
                                    {
                                        if (TipoPago == "3 Meses                  ")
                                        {
                                            FechaVen = fecha.AddMonths(3);
                                            TOTAL    = 6;
                                        }
                                        else
                                        {
                                            if (TipoPago == "6 Meses                  ")
                                            {
                                                FechaVen = fecha.AddMonths(3);
                                                TOTAL    = 7;
                                            }
                                            else
                                            {
                                                if (TipoPago == "Anual                    ")
                                                {
                                                    FechaVen = fecha.AddYears(1);
                                                    TOTAL    = 8;
                                                }
                                                else
                                                {
                                                    FechaVen = fecha;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    pTPago = FechaVen.ToString("yyyy-MM-dd");

                    if (FechaVen > FechaH)
                    {
                        textEstado.Text = "ACTIVO";
                    }
                    else
                    {
                        textEstado.Text = "VENCIDO";
                    }
                    Console.WriteLine(FechaVen);
                    Console.WriteLine(FechaH);
                }
                Conectar.Cerrar();
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.ToString());
            }

            try
            {
                ConexionHuella conexionHuella = new ConexionHuella();
                conexionHuella.Abrir();
                string     comando = "SELECT * FROM HUELLASCLIENTES WHERE ID=@ID";
                SqlCommand cmd     = new SqlCommand(comando, conexionHuella.Conectarbd);
                cmd.Parameters.AddWithValue("@ID", Convert.ToInt64(NroDocumento.Text));
                SqlDataReader reader = cmd.ExecuteReader();
                int           ok     = 0;
                while (reader.Read())
                {
                    ok = ok + 1;
                }
                if (ok == 1)
                {
                    button6.Visibility      = Visibility.Visible;
                    button6_Copy.Visibility = Visibility.Collapsed;
                }
                else
                {
                    button6_Copy.Visibility = Visibility.Visible;
                    button6.Visibility      = Visibility.Collapsed;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #4
0
        private static List <ListaR> LisRegist(Int64 IdUsser)
        {
            try
            {
                DateTime       Hoy            = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                DateTime       Manana         = Hoy.AddDays(1);
                List <ListaR>  listas         = new List <ListaR>();
                ConexionHuella conexionHuella = new ConexionHuella();
                conexionHuella.Abrir();
                string     comando = "SELECT ID,FECHAYHORA FROM REGISTROS WHERE (FECHAYHORA>=@FECHAHOY AND FECHAYHORA<@FECHAMANANA) AND(IDUSUARIO=@USSERACTIVO)";
                SqlCommand cmd     = new SqlCommand(comando, conexionHuella.Conectarbd);
                cmd.Parameters.AddWithValue("@FECHAHOY", Hoy);
                cmd.Parameters.AddWithValue("@FECHAMANANA", Manana);
                cmd.Parameters.AddWithValue("@USSERACTIVO", IdUsser);

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    ListaR listaR = new ListaR();
                    listaR.Documento = reader["ID"].ToString();
                    Int64    Pdoc      = Convert.ToInt64(listaR.Documento);
                    DateTime FechaHora = Convert.ToDateTime(reader["FECHAYHORA"]);
                    listaR.Fecha_y_Hora = FechaHora.ToString("HH:mm tt");
                    Conexion conexion = new Conexion();
                    conexion.Abrir();
                    string     com  = "SELECT NOMBRE,APELLIDO,NINGRESOS.FECHA_INICIO,INGRESOS.TIPO_INGRE FROM CLIENTES INNER JOIN  (select max(FECHA_INICIO)AS FECHA_INICIO,DOC_CLIENTE from INGRESOS group by DOC_CLIENTE) AS NINGRESOS  ON NINGRESOS.DOC_CLIENTE = CLIENTES.ID_CLIENTE INNER JOIN INGRESOS ON NINGRESOS.DOC_CLIENTE = INGRESOS.DOC_CLIENTE AND NINGRESOS.FECHA_INICIO=INGRESOS.FECHA_INICIO WHERE CLIENTES.ID_CLIENTE=@IDCLIENTE ";
                    SqlCommand cmd2 = new SqlCommand(com, conexion.Conectarbd);
                    cmd2.Parameters.AddWithValue("@IDCLIENTE", Pdoc);

                    SqlDataReader reader2 = cmd2.ExecuteReader();
                    while (reader2.Read())
                    {
                        listaR.Nombre   = reader2["NOMBRE"].ToString();
                        listaR.Apellido = reader2["APELLIDO"].ToString();
                        string TipoPago = reader2["TIPO_INGRE"].ToString();
                        listaR.Tipo_Pago = reader2["TIPO_INGRE"].ToString();
                        DateTime FechaIni = Convert.ToDateTime(reader2["FECHA_INICIO"].ToString());
                        DateTime FechaVen;
                        switch (TipoPago)
                        {
                        case "Mensual                  ":
                            FechaVen = FechaIni.AddMonths(1);
                            break;

                        case "Semanal                  ":
                            FechaVen = FechaIni.AddDays(7);
                            break;

                        case "Quincenal                ":
                            FechaVen = FechaIni.AddDays(15);
                            break;

                        case "2 Meses                  ":
                            FechaVen = FechaIni.AddMonths(2);
                            break;

                        case "3 Meses                  ":
                            FechaVen = FechaIni.AddMonths(3);
                            break;

                        case "6 Meses                  ":
                            FechaVen = FechaIni.AddMonths(6);
                            break;

                        case "Anual                    ":
                            FechaVen = FechaIni.AddYears(1);
                            break;

                        default:
                            FechaVen = FechaIni;
                            break;
                        }
                        listaR.Fecha_Vencimiento = FechaVen.ToString("dddd,dd MMMM yyyy");
                    }
                    conexion.Cerrar();
                    listas.Add(listaR);
                }
                conexionHuella.Cerrar();
                return(listas);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(null);
            }
        }