Пример #1
0
        private int filtrarPedidoconCategoriasDisponibles(int OrderId)
        {
            string QueryDetalle = "";

            if (LeerXml().Length > 0)
            {
                QueryDetalle = "SELECT pd.idDetalle,pd.idPedido,pd.idProducto,p.nombre as producto,pd.cantidad,pd.cantidadAnterior,pd.precio,pd.subTotal,pd.grupo,pd.idCocinero,pd.extras,DATE_FORMAT(pd.horaPedido, '%Y-%m-%d %H:%i:%s') as horaPedido,DATE_FORMAT(pd.horaEntregado, '%Y-%m-%d %H:%i:%s') as horaEntregado,pe.fecha,m.idMesa,m.nombre as mesa from pedido_detalle pd, producto p, pedido pe  left join mesa m on (pe.idMesa=m.idMesa) where pd.idProducto = p.idProducto and pd.idpedido = pe.idPedido and p.idFamilia in (" + LeerXml() + " ) and pe.idPedido=" + OrderId;
            }
            else
            {
                QueryDetalle = "SELECT pd.idDetalle,pd.idPedido,pd.idProducto,p.nombre as producto,pd.cantidad,pd.cantidadAnterior,pd.precio,pd.subTotal,pd.grupo,pd.idCocinero,pd.extras,DATE_FORMAT(pd.horaPedido, '%Y-%m-%d %H:%i:%s') as horaPedido,DATE_FORMAT(pd.horaEntregado, '%Y-%m-%d %H:%i:%s') as horaEntregado,pe.fecha,m.idMesa,m.nombre as mesa from pedido_detalle pd, producto p, pedido pe  left join mesa m on (pe.idMesa=m.idMesa) where pd.idProducto = p.idProducto and pd.idpedido = pe.idPedido and pe.idPedido=" + OrderId;
            }

            DBM.CLS.QUERY Query           = new DBM.CLS.QUERY();
            DBM.CLS.QUERY consultaDetalle = new DBM.CLS.QUERY();
            DataTable     DT = new DataTable();

            DT = consultaDetalle.Consultar(QueryDetalle);
            if (DT != null)
            {
                return(DT.Rows.Count);
            }
            else
            {
                return(0);
            }
        }
Пример #2
0
        private void filtrarVentas()
        {
            ///********************************************************
            DBM.CLS.QUERY Query = new DBM.CLS.QUERY();
            //string sql = "SELECT pd.idDetalle,pd.idPedido,pd.idProducto,p.nombre as producto,pd.cantidad,pd.precio,pd.subTotal,pd.grupo,pd.idCocinero,pd.extras,DATE_FORMAT(pd.horaPedido, '%Y-%m-%d %H:%i:%s') as horaPedido,DATE_FORMAT(pd.horaEntregado, '%Y-%m-%d %H:%i:%s') as horaEntregado,pe.fecha from pedido_detalle pd, producto p, pedido pe where pd.idProducto = p.idProducto and pd.idpedido = pe.idPedido " + _filtro + " ;";
            //Query.Consultar(sql);
            if (txtFecha1.TextLength > 0 && txtFecha2.TextLength > 0)
            {
                filtro = " CAST(fecha AS DATE)>='" + txtFecha1.Text + "' and CAST(fecha AS DATE) <='" + txtFecha2.Text + "' and anular=0";
            }
            if (txtFecha1.TextLength > 0 && txtFecha2.TextLength == 0)
            {
                filtro = " CAST(fecha AS DATE)='" + txtFecha1.Text + "' and anular=0";
            }

            ///********************************************************
            //string sql = "SELECT *,MONTH(a.fecha) as mes from pedido where " + filtro + ";";
            string sql = "SELECT *,Date_format(fecha,'%M') as mes from pedido where " + filtro + ";";

            try
            {
                if (filtro.Length > 0)
                {
                    DTVentas = Query.Consultar(sql);
                }
            }
            catch
            {
            }
        }
Пример #3
0
        private DataRow InfoEmpresa()
        {
            DBM.CLS.QUERY Query = new DBM.CLS.QUERY();
            DataRow       drE   = Query.GetRecordTop("empresa");

            return(drE);
        }
Пример #4
0
        private void filtrarMaterias()
        {
            try
            {
                DBM.CLS.QUERY Query = new DBM.CLS.QUERY();

                DataTable dtMateria = new DataTable();
                DataRow   dr;
                dtMateria = Query.GetRecords("estado");

                for (int i = 0; i < dtMateria.Rows.Count; i++)
                {
                    dr = dtMateria.Rows[i];

                    DBM.CLS.Metodos.myButton MyButton = new DBM.CLS.Metodos.myButton();
                    MyButton.Width     = 200;
                    MyButton.Height    = 80;
                    MyButton.Font      = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular);
                    MyButton.BackColor = Color.FromName(dr["color"].ToString());

                    //MyButton.ForeColor = Color.White;
                    MyButton.campo1 = dr["idEstado"].ToString();
                    MyButton.campo2 = dr["estado"].ToString();
                    MyButton.Text   = dr["estado"].ToString();

                    MyButton.Click_ConIndice += myButton_Click;
                    MyPanel.Controls.Add(MyButton);
                }
            }
            catch
            {
            }
        }
Пример #5
0
        //***************************************************************************************
        //* LLENAR TODOS LOS GRID VIEW y COMBOBOX
        //***************************************************************************************
        private void LlenarGrid()
        {
            DBM.CLS.QUERY Query = new DBM.CLS.QUERY();
            DataTable     DT    = Query.GetRecordsFromTwoTable("empleado", "usuario", "idEmpleado", "idUsuario", "", "apellidos");

            DBM.CLS.Funciones.FillGridView(dgUsuario, DT);
        }
Пример #6
0
        private Boolean Validar()
        {
            Boolean Resultado = false;

            DBM.CLS.QUERY objConsulta = new DBM.CLS.QUERY();
            objConsulta.showErrorSQL = false;
            DataTable dtUser = new DataTable();

            dtUser = objConsulta.GetRecordsFilters("usuario", "pinCode", "MD5(" + txtpinCode.Text + ")");
            if (dtUser.Rows.Count > 0)
            {
                DataRow dr = dtUser.Rows[0];
                DataRow drE;
                _SESION.Perfil    = dr["idRol"].ToString();
                _SESION.idUsuario = dr["idUsuario"].ToString();

                DataTable DTE = objConsulta.GetRecordsFilters("empleado", "idEmpleado", _SESION.idUsuario);
                if (DTE.Rows.Count > 0)
                {
                    drE             = DTE.Rows[0];
                    _SESION.Usuario = drE["nombres"].ToString();
                }

                Resultado = true;
            }
            return(Resultado);
        }
Пример #7
0
 private void txtCliente_TextChanged(object sender, EventArgs e)
 {
     if (txtIdCliente.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgCliente, Tabla.GetRecordsFiltersLike("cliente", "nombre", txtNombre.Text));
     }
 }
Пример #8
0
 private void txtProducto_TextChanged(object sender, EventArgs e)
 {
     if (txtIdProducto.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgProducto, Tabla.GetRecordsFiltersLike("producto", "descripcion", txtDescripcion.Text));
     }
 }
Пример #9
0
 private void txtMarca_TextChanged(object sender, EventArgs e)
 {
     if (txtIdMarca.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgMarcas, Tabla.GetRecordsFiltersLike("marca", "marca", txtMarca.Text));
     }
 }
Пример #10
0
 private void txtProveedor_TextChanged(object sender, EventArgs e)
 {
     if (txtidProveedor.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgProveedor, Tabla.GetRecordsFiltersLike("proveedor", "nombre", txtNombreProv.Text));
     }
 }
Пример #11
0
 private void txtCategoria_TextChanged(object sender, EventArgs e)
 {
     if (txtIdCategoria.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgCategoria, Tabla.GetRecordsFiltersLike("Familia", "Familia", txtCategoria.Text));
     }
 }
Пример #12
0
 private void txtEstado_TextChanged(object sender, EventArgs e)
 {
     if (txtIdEstado.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgEstado, Tabla.GetRecordsFiltersLike("Estado", "Estado", txtEstado.Text));
     }
 }
Пример #13
0
 private void txtPresentacion_TextChanged(object sender, EventArgs e)
 {
     if (txtIdPresentacion.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgPresentacion, Tabla.GetRecordsFiltersLike("UnidadMedida", "UnidadMedida", txtPresentacion.Text));
     }
 }
Пример #14
0
 private void txtUsuario_TextChanged(object sender, EventArgs e)
 {
     if (txtIdUsuario.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgUsuario, Tabla.GetRecordsFiltersLike("usuario", "nombre", txtNombres.Text));
     }
 }
Пример #15
0
 private void txtPerfil_TextChanged(object sender, EventArgs e)
 {
     if (txtIdPerfil.TextLength <= 0)
     {
         DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgPerfil, Tabla.GetRecordsFiltersLike("Rol", "Rol", txtPerfil.Text));
     }
 }
Пример #16
0
 private void cargarGridQueryByIDCaja()
 {
     if (txtQueryIDCaja.TextLength > 0)
     {
         //String filtro = " CAST(fecha AS DATE)>='" + txtFecha1.Text + "' and CAST(fecha AS DATE) <='" + txtFecha2.Text+"'";
         DBM.CLS.QUERY objQuery = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgQuery, objQuery.GetRecordsFilters("egreso", "idCaja", txtQueryIDCaja.Text));
     }
 }
Пример #17
0
 private void CargarPermisosOtorgados()
 {
     try
     {
         int.Parse(cboPerfil.SelectedValue.ToString());
         DBM.CLS.QUERY Query = new DBM.CLS.QUERY();
         DBM.CLS.Funciones.FillGridView(dgOtorgados, Query.GetRecordsFilters("Comando", "idComando", " IN(", "SELECT idComando FROM permiso p WHERE idRol = " + cboPerfil.SelectedValue.ToString() + ") "));
     }
     catch { }
 }
Пример #18
0
 private void cargarGridQuery()
 {
     //if (txtQueryIDCaja.TextLength > 0)
     //{
     filtro = " CAST(fecha AS DATE) BETWEEN '" + txtFecha1.Text + "' AND '" + txtFecha2.Text + "'";
     //String filtro = " CAST(fecha AS DATE)>='" + txtFecha1.Text + "' and CAST(fecha AS DATE) <='" + txtFecha2.Text+"'";
     DBM.CLS.QUERY objQuery = new DBM.CLS.QUERY();
     //DBM.CLS.Funciones.FillGridView(dgQuery, objQuery.GetRecordsFilters("egreso", "1", filtro));
     DBM.CLS.Funciones.FillGridView(dgQuery, objQuery.GetRecordsFromTwoTableLEFTJOIN("egreso", "egreso_tipo", "idEgresoTipo", "idEgresoTipo", filtro, "a.fecha"));
     //}
 }
Пример #19
0
        private int GetOrndenPedidoPendiente2()
        {
            int resultado = 0;

            DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
            DataTable     DT    = Tabla.GetRecordsFilters("Pedido", "listo", "0");

            foreach (DataRow dr in DT.Rows)
            {
                resultado = int.Parse(dr["idPedido"].ToString());
                break;
            }
            return(resultado);
        }
Пример #20
0
        private void filtrarEgresos()
        {
            DBM.CLS.QUERY Query = new DBM.CLS.QUERY();
            filtro = " CAST(fecha AS DATE) BETWEEN '" + txtFecha1.Text + "' AND '" + txtFecha2.Text + "'";
            //string sql = "Select a.*, b.*,MONTH(a.fecha) as mes from egreso  a left join egreso_tipo b on(a.idEgresoTipo= b.idEgresoTipo) where " + filtro + " order by a.fecha ";
            string sql = "Select a.*, b.*,Date_format(a.fecha,'%M') as mes from egreso  a left join egreso_tipo b on(a.idEgresoTipo= b.idEgresoTipo) where " + filtro + " order by a.fecha ";

            try
            {
                DTEgresos = Query.Consultar(sql);
            }
            catch
            {
            }
        }
Пример #21
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            DBM.CLS.QUERY Query = new DBM.CLS.QUERY();
            if (Query.GetContadorVistas() <= 0)
            {
                CLS.ConfigBD config = new CLS.ConfigBD();
                if (config.crearVistaKardex())
                {
                    MessageBox.Show("La vista de datos ya fué crada con éxito, vuela a intentar mostrar los datos", ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            string filtro = "";

            if (picturekOk1.Visible && picturekOk2.Visible)
            {
                filtro = " AND fecha >='" + dateStart.Value.ToString("yyyy-MM-dd") + "' and CAST(fecha AS DATE) <='" + dateEnd.Value.ToString("yyyy-MM-dd") + "' ";
            }
            else if (picturekOk1.Visible)
            {
                filtro = " AND fecha >='" + dateStart.Value.ToString("yyyy-MM-dd") + "' ";
            }
            else if (picturekOk2.Visible)
            {
                filtro = " AND fecha <='" + dateEnd.Value.ToString("yyyy-MM-dd") + "' ";
            }
            else //mostrar todos
            {
                filtro = "";
            }

            if (chkFiltro.Checked)
            {
                GUI.bProducto frm = new GUI.bProducto();
                frm.ShowDialog();
                if (frm.id != null && frm.id.Length > 0)
                {
                    txtIdProducto.Text = frm.id;
                    txtProducto.Text   = frm.nombreProducto;
                    DBM.CLS.Funciones.FillGridView(dgKardex, Query.GetRecordsFilters("kardex", "idProducto", txtIdProducto.Text + filtro + " ORDER BY fecha DESC "));
                }
            }
            else
            {
                string sql = "SELECT *  from kardex where" + filtro;
                DBM.CLS.Funciones.FillGridView(dgKardex, Query.GetRecordsFilters("kardex", "1", "1" + filtro + " ORDER BY FECHA DESC"));
            }
        }
        public DataTable Consultar(Query QuerySelected)
        {
            DataTable     Resultado = new DataTable();
            StringBuilder Sentencia = new StringBuilder();

            // StringBuilder es para concatenar cadenas, se usa para cadenas complejas.
            switch (QuerySelected)
            {
            case Query.CONVERTIR_UTF8:
                Sentencia.Append("SET NAMES 'utf8'");
                break;

            case Query.VALIDAR_USUARIO:
                Sentencia.Append("SELECT u.idUsuario, e.nombres, e.apellidos,u.idRol,u.pinCode FROM usuario u, empleado e where u.idUsuario = e.idEmpleado and u.pinCode=md5('" + _pinCode + "')");
                break;

            case Query.VALIDAR_USUARIO_ADMINISTRADOR:
                Sentencia.Append("SELECT u.idUsuario, e.nombres, e.apellidos,u.idRol,u.pinCode FROM usuario u, empleado e where u.idUsuario = e.idEmpleado and u.idRol = '1' and u.pinCode=md5('" + _pinCode + "')");
                break;

            case Query.VALIDAR_USUARIO_MESERO:
                Sentencia.Append("SELECT u.idUsuario, e.nombres, e.apellidos,u.idRol,u.pinCode FROM usuario u, empleado e where u.idUsuario = e.idEmpleado and u.idRol = '2' and u.pinCode=md5('" + _pinCode + "')");
                break;

            case Query.PERMISOS_OTORGADOS:
                Sentencia.Append("SELECT idComando, comando FROM comando c WHERE idComando IN (SELECT idComando FROM permiso p WHERE idRol=" + _filtro + ") order by idComando;");
                break;

            case Query.PERMISOS_DISPONIBLES:
                Sentencia.Append("SELECT idComando, comando FROM comando c WHERE idComando NOT IN (SELECT idComando FROM permiso p WHERE idRol=" + _filtro + ")  order by idComando;");
                break;

            case Query.EMPLEADOS_ENROLADOS:
                Sentencia.Append("SELECT idEmpleado, concat(nombres, ' ', apellidos) as nombreEmp FROM empleado e WHERE idEmpleado IN (SELECT idUsuario FROM usuario u WHERE idRol=" + _filtro + ");");
                break;

            case Query.EMPLEADOS_SIN_ROLES:
                Sentencia.Append("SELECT idEmpleado, concat(nombres, ' ', apellidos) as nombreEmp FROM empleado e WHERE idEmpleado NOT IN (SELECT idUsuario FROM usuario u)");
                break;

            case Query.TODOS_LOS_USUARIOS:
                Sentencia.Append("SELECT u.idUsuario, e.nombres,e.apellidos,e.direccion,e.email,e.telefono,e.DUI,e.NIT,e.sueldoBase,e.comision,r.rol FROM usuario u, empleado e, rol r where u.idEmpleado = e.idEmpleado and u.idRol= r.idRol ORDER BY e.nombres ASC;");
                break;
            }
            DBM.CLS.QUERY objDatos = new DBM.CLS.QUERY();
            Resultado = objDatos.Consultar(Sentencia.ToString());
            return(Resultado);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            CLS.Connection cnxValidate = new CLS.Connection();

            CLS.Utilities objConx   = new CLS.Utilities();
            string        newString = null;

            newString = objConx.SetConnectionStringComplete(txtServer.Text, uint.Parse(txtPort.Text), txtBD.Text, txtUser.Text, txtPass.Text);
            if (chkVerify.Checked)
            {
                if (cnxValidate.ValidarConexion(newString))
                {
                    MessageBox.Show("Conexión exitosa", "ConnectionSettings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (newString != null)
                    {
                        objConx.SaveConnectionString(newString);
                        objConx.ProtectConnectionString();

                        DBM.CLS.QUERY Query_ = new DBM.CLS.QUERY();
                        Query_.GetColumnWidth("pedido", "listo");
                        if (Query_.GetColumnWidth("pedido", "listo")["COLUMN_TYPE"].ToString().Trim() == "tinyint(1)")
                        {
                            DBM.CLS.Transaccion Trans = new DBM.CLS.Transaccion();
                            string query = "";
                            query = "ALTER TABLE `pedido` CHANGE `listo` `listo` TINYINT(2) NULL DEFAULT NULL;";

                            if (Trans.CreateTransaction(query))
                            {
                                MessageBox.Show("El campo LISTO ahora tiene un ancho de 2 ", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No se pudo establecer la conexión con el servidor." + saltoLinea + "Para guardar los datos sin comprobar la conexión desactive la casilla de verificación", "ConnectionSettings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                if (newString != null)
                {
                    objConx.SaveConnectionString(newString);
                    objConx.ProtectConnectionString();
                }
            }
        }
Пример #24
0
        private void cargarEntrada()
        {
            DBM.CLS.QUERY Tabla = new DBM.CLS.QUERY();
            DataTable     DT    = Tabla.GetRecordsFilters("Pedido", "cancelado", "=", "0");
            int           i     = 0;

            foreach (DataRow dr in DT.Rows)
            {
                int esta = Byte.Parse(dr["listo"].ToString());
                ///////////////Prueba
                bool btnnuevo = true;
                foreach (Control item in flowPanelPendiente.Controls)
                {
                    if (item.Name == dr["idPedido"].ToString())
                    {
                        btnnuevo = false;
                        break;
                    }
                }
                foreach (Control item in flowPanelProceso.Controls)
                {
                    if (item.Name == dr["idPedido"].ToString())
                    {
                        btnnuevo = false;
                        break;
                    }
                }
                foreach (Control item in flowPanelFinalizado.Controls)
                {
                    if (item.Name == dr["idPedido"].ToString())
                    {
                        btnnuevo = false;
                        break;
                    }
                }
                /////////////// 17-08-2019
                if (btnnuevo)
                {
                    int MaxIdeDetalle = Tabla.MaximoValor("idDetalle", "pedido_detalle", "idPedido", dr["idPedido"].ToString());
                    creaBotonEntrar(int.Parse(dr["idPedido"].ToString()), dr["total"].ToString(), MaxIdeDetalle, esta);
                }
                i++;
            }
        }
Пример #25
0
        private Double obtenerSaldoCaja()
        {
            Double getSaldo = 0.0;

            DBM.CLS.QUERY objQuery = new DBM.CLS.QUERY();
            dataTableEgreso = objQuery.GetRecordsFilters("caja", "estado", "1");
            if (dataTableEgreso.Rows.Count > 0)
            {
                for (int i = 0; i < objQuery.GetRecordsFilters("caja", "estado", "1").Rows.Count; i++)
                {
                    DataRow dr = dataTableEgreso.Rows[i];
                    getSaldo      = Double.Parse(dr["saldo"].ToString());
                    idCajaAbierta = dr["idCaja"].ToString();
                }
            }
            txtIdCaja.Text  = idCajaAbierta;
            txtUsuario.Text = _SESION.Usuario;
            return(getSaldo);
        }
Пример #26
0
        private void quitarePedidosPagados()
        {
            DBM.CLS.QUERY QueryTable = new DBM.CLS.QUERY();
            DataRow       drOrder;

            foreach (DBM.CLS.Metodos.myButton item in flowPanelFinalizado.Controls.OfType <Button>())
            {
                drOrder = QueryTable.GetUniqueRecord("Pedido", "idPedido", item.Name);
                if (drOrder != null)
                {
                    try
                    {
                        if (item.campo1 == drOrder["idPedido"].ToString() && bool.Parse(drOrder["cancelado"].ToString()) == true)
                        {
                            flowPanelFinalizado.Controls.Remove(item);
                        }
                    }
                    catch { }
                }
            }
        }
Пример #27
0
        private void ValidaPedido_NoEliminado()
        {
            DBM.CLS.QUERY QueryTable = new DBM.CLS.QUERY();
            DataRow       drOrder;

            foreach (Control item in flowPanelPendiente.Controls)
            {
                if ((drOrder = QueryTable.GetUniqueRecord("Pedido", "idPedido", item.Name)) == null)
                {
                    flowPanelPendiente.Controls.Remove(item);
                }
            }
            foreach (Control item in flowPanelProceso.Controls)
            {
                if ((drOrder = QueryTable.GetUniqueRecord("Pedido", "idPedido", item.Name)) == null)
                {
                    //flowPanelProceso.Controls.Remove(item);
                    item.BackColor = Color.Red;
                    item.Enabled   = false;
                    item.Text      = item.Text + " Cancelada";
                }
            }
        }
Пример #28
0
        //************************************************************************
        // MANTENIMIENTO PRODUCCTO GRIDVIEW
        //************************************************************************

        //*****************************************************************************
        //* MANTENIMIENTO PRODUCTO INDIVIDUAL(SIN GRIDVIEW)
        //*****************************************************************************
        private void btnUsuarioNewSave_Click(object sender, EventArgs e)
        {
            int NewId = 0;

            if (btnUsuarioNewSave.Tag.ToString() == "1")
            {
                btnUsuarioNewSave.Tag      = "2";
                btnUsuarioNewSave.Image    = Resources.save;
                btnUsuarioEditCancel.Tag   = "2";
                btnUsuarioEditCancel.Image = Properties.Resources.cancel;
                groupBoxUsuario.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = false);
                txtIdUsuario.ReadOnly = true;
                txtNombres.Focus();
                LimpiarForm();
                chkChangePassword.Visible = false;
            }
            else
            {
                if (txtNombres.TextLength > 0)
                {
                    DBM.CLS.QUERY query = new DBM.CLS.QUERY();
                    DBM.CLS.CRUD  Tabla = new DBM.CLS.CRUD();

                    List <string> campos = new List <string>();
                    campos.Add("idEmpleado");
                    campos.Add("nombres");
                    campos.Add("apellidos");
                    campos.Add("email");
                    campos.Add("telefono");
                    campos.Add("idRol");

                    List <string> valores = new List <string>();
                    if (txtIdUsuario.TextLength > 0)
                    {
                        valores.Add(txtIdUsuario.Text);
                    }
                    else
                    {
                        NewId = (Tabla.GetNewId("usuario", "idUsuario") > 0) ? Tabla.GetNewId("usuario", "idUsuario") : (Tabla.GetNewId("usuario", "idUsuario") + 1);
                        valores.Add(NewId.ToString());
                    }
                    valores.Add(txtNombres.Text);
                    valores.Add(txtEmail.Text);
                    valores.Add(txtTelefono.Text);

                    valores.Add(cboPerfil.SelectedValue.ToString());
                    bool actualizacion, continuar = false;
                    int  filaActual = 0;
                    if (txtIdUsuario.TextLength > 0)
                    {
                        actualizacion = true;
                        filaActual    = dgUsuario.CurrentRow.Index;
                        if (chkChangePassword.Checked)
                        {
                            campos.Add("password");
                            valores.Add(query.GetSHA1FromString(txtPassword.Text));
                            continuar = ComprobarDatos();
                            if (continuar)
                            {
                                Tabla.Update("usuario", campos, valores, "idUsuario", txtIdUsuario.Text);
                            }
                        }
                        else
                        {
                            Tabla.Update("usuario", campos, valores, "idUsuario", txtIdUsuario.Text);
                            continuar = true;
                        }
                    }
                    else
                    {
                        campos.Add("password");
                        valores.Add(query.GetSHA1FromString(txtPassword.Text));
                        actualizacion = false;
                        if (continuar = ComprobarDatos())
                        {
                            Tabla.Insert("usuario", campos, valores);
                        }
                    }
                    if (continuar)
                    {
                        chkChangePassword.Checked  = false;
                        btnUsuarioNewSave.Tag      = "1";
                        btnUsuarioNewSave.Image    = Properties.Resources.new_;
                        btnUsuarioEditCancel.Tag   = "1";
                        btnUsuarioEditCancel.Image = Properties.Resources.edit;
                        groupBoxUsuario.Controls.OfType <TextBox>().ToList().ForEach(o => o.ReadOnly = true);
                        LlenarGrid();
                        if (actualizacion)
                        {
                            dgUsuario.CurrentCell = dgUsuario.Rows[filaActual].Cells[0];
                        }
                        else
                        {
                            filaActual            = dgUsuario.Rows.Count - 1;
                            dgUsuario.CurrentCell = dgUsuario.Rows[dgUsuario.RowCount - 1].Cells[0];
                            //dgProducto.CurrentCell = dgProducto.Rows[filaActual].Cells[0];
                        }
                        LimpiarForm();
                        chkChangePassword.Visible = false;
                    }
                }
                else
                {
                    //MENSAJE VACIOS
                }
            }
        }
Пример #29
0
 private void txtFiltro_TextChanged(object sender, EventArgs e)
 {
     DBM.CLS.QUERY Table = new DBM.CLS.QUERY();
     DBM.CLS.Funciones.FillGridView(dgUsuario, Table.GetRecordsFiltersLike("usuario", "nombre", txtFiltro.Text));
 }
Пример #30
0
 private void llenarGrid()
 {
     DBM.CLS.QUERY Query = new DBM.CLS.QUERY();
     DBM.CLS.Funciones.FillGridView(dgFamilia, Query.Consultar("select idFamilia,familia,'1' as enMonitor from familia order by familia"));
 }