示例#1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            Usuario json = new Usuario();

            json.idUsuario = Convert.ToInt16(txtID.Text);
            data           = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented);
            data2         += data;
            data2         += "]";
            using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
            {
                try
                {
                    client.bajaUsuario(data2);

                    MessageBox.Show("¡Usuario eliminado! :)");
                    data  = "";
                    data2 = "[";
                    ActualizarTabla();
                }
                catch
                {
                    MessageBox.Show("No sirvio :(");
                }
            }
        }
示例#2
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            Producto json = new Producto();

            json.nombre       = txtNombre.Text;
            json.marca        = txtMarca.Text;
            json.descripcion  = txtDescripcion.Text;
            json.precioVenta  = Convert.ToDecimal(textPV.Text);
            json.precioCompra = Convert.ToDecimal(textPC.Text);
            json.caducidad    = textCaducidad.Text;
            json.stock        = Convert.ToInt16(txtCantidad.Text);
            json.medida       = cbUnidad.SelectedIndex;
            json.departamento = cbDepartamento.SelectedIndex;
            json.provedor     = cbProvedor.SelectedIndex;
            data   = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented) + "]";
            data2 += data;

            using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
            {
                try
                {
                    client.buscarProducto(data2);
                    MessageBox.Show("Resultados");
                    data  = "";
                    data2 = "[";
                }
                catch
                {
                    MessageBox.Show("No sirvio :(");
                }
            }
        }
示例#3
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            Usuario json = new Usuario();

            json.nombre           = txtNombre.Text;
            json.apellido         = txtApellidos.Text;
            json.fecha_nacimiento = txtNacimiento.Text;
            json.direccion        = txtDireccion.Text;
            json.telefono         = txtTelefono.Text;
            json.correo           = txtCorreo.Text;
            json.password         = txtPassword.Text;
            json.permiso          = comboBox1.SelectedIndex;
            json.idUsuario        = Convert.ToInt16(txtID.Text);
            data   = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented) + "]";
            data2 += data;

            using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
            {
                try
                {
                    client.actualizarUsuario(data2);
                    MessageBox.Show("Usuario modificado correctamente.");
                    data  = "";
                    data2 = "[";
                    ActualizarTabla();
                }
                catch
                {
                    MessageBox.Show("No sirvio :(");
                }
            }
        }
示例#4
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            if (txtRazonSocial.Text == "" || txtDomicilioFiscal.Text == "" || txtRFC.Text == "" || txtTelefono.Text == "" || txtCorreo.Text == "")
            {
                MessageBox.Show("Falta rellenar uno o mas campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                Proveedor json = new Proveedor();
                //json.IDProveedor = Convert.ToInt16(txtID.Text);
                json.razonSocial     = txtRazonSocial.Text;
                json.domicilioFiscal = txtDomicilioFiscal.Text;
                json.rfc             = txtRFC.Text;
                json.telefono        = txtTelefono.Text;
                json.correo          = txtCorreo.Text;
                data   = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented) + "]";
                data2 += data;

                using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
                {
                    try
                    {
                        client.actualizarProveedor(data2);
                        MessageBox.Show("Proveedor modificado correctamente.");
                        data  = "";
                        data2 = "[";
                        ActualizarTabla();
                    }
                    catch
                    {
                        MessageBox.Show("No sirvio :(");
                    }
                }
            }
        }
示例#5
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Está seguro de eliminar este elemento? Esta acción no se puede deshacer.", "Eliminar proveedor", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            {
                Proveedor json = new Proveedor();
                json.idProvedor = Convert.ToInt16(txtID.Text);
                data            = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented);
                data2          += data;
                data2          += "]";
                txtID.Text      = data2;
                using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
                {
                    try
                    {
                        client.bajaProveedor(data2);

                        MessageBox.Show("¡Proveedor eliminado! :)");
                        data  = "";
                        data2 = "[";
                    }
                    catch
                    {
                        MessageBox.Show("No sirvio :(");
                    }
                }
            }
        }
示例#6
0
 public void ActualizarTabla()
 {
     using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
     {
         try
         {
             DataTable dt = (DataTable)JsonConvert.DeserializeObject(client.cargarProducto(), typeof(DataTable));
             dgvTabla.DataSource = dt;
         }
         catch
         {
             MessageBox.Show("No sirvio Tabla :(");
         }
     }
 }
示例#7
0
        private void txtBuscar_TextChanged(object sender, EventArgs e)
        {
            using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
            {
                try
                {
                    DataTable dt = (DataTable)JsonConvert.DeserializeObject(client.buscarUsuario(txtBuscar.Text), typeof(DataTable));

                    dataGridView1.DataSource = dt;
                }
                catch
                {
                    MessageBox.Show("No sirvio :(");
                }
            }
        }
示例#8
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text != "" && txtMarca.Text != "" && txtDescripcion.Text != "" && cbDepartamento.Text != "" && cbProvedor.Text != "" && textPC.Text != "" && textPV.Text != "" && textCaducidad.Text != "" && txtCantidad.Text != "" && cbUnidad.Text != "")
            {
                if (MessageBox.Show("¿Esta seguro Agregar este este producto al sistema?", "Salir", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    Producto json = new Producto();
                    json.nombre       = txtNombre.Text;
                    json.marca        = txtMarca.Text;
                    json.descripcion  = txtDescripcion.Text;
                    json.precioVenta  = Convert.ToDecimal(textPV.Text);
                    json.precioCompra = Convert.ToDecimal(textPC.Text);
                    json.caducidad    = textCaducidad.Text;
                    json.stock        = Convert.ToInt16(txtCantidad.Text);
                    json.medida       = cbUnidad.SelectedIndex;
                    json.departamento = cbDepartamento.SelectedIndex;
                    json.provedor     = cbProvedor.SelectedIndex;

                    data   = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented) + "]";
                    data2 += data;

                    using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
                    {
                        try
                        {
                            client.altaProducto(data2);
                            MessageBox.Show("Producto Insertado! :)");
                            data  = "";
                            data2 = "[";
                            ActualizarTabla();
                        }
                        catch
                        {
                            MessageBox.Show("No sirvio :(");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Por favor llena todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#9
0
        public void ActualizarDepartamento()
        {
            using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
            {
                try
                {
                    String respuestaDepa   = client.cargarCatDepartamento();
                    String respuestaProv   = client.cargarCatProveedor();
                    String respuestaMedida = client.cargarCatMedida();
                    //MessageBox.Show("y ahora"+respuesta);
                    var a = JsonConvert.DeserializeObject <List <Departamento> >(respuestaDepa);
                    var b = JsonConvert.DeserializeObject <List <Proveedor> >(respuestaProv);
                    var c = JsonConvert.DeserializeObject <List <Medida> >(respuestaMedida);
                    foreach (var depa in a)
                    {
                        ComboBoxItem item = new ComboBoxItem();
                        item.Text  = depa.nombre;
                        item.Value = depa.idDepartamento;
                        cbDepartamento.Items.Add(item);
                    }

                    foreach (var prov in b)
                    {
                        ComboBoxItem item = new ComboBoxItem();
                        item.Text  = prov.RazonSocial;
                        item.Value = prov.IDProveedor;
                        cbProvedor.Items.Add(item);
                    }

                    foreach (var med in c)
                    {
                        ComboBoxItem item = new ComboBoxItem();
                        item.Text  = med.nombre;
                        item.Value = med.idMedida;
                        cbUnidad.Items.Add(item);
                    }
                }
                catch
                {
                    MessageBox.Show("No sirvio :(Auxilio");
                }
            }
        }
示例#10
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
            {
                try
                {
                    String cadena = client.buscarLogin(Convert.ToInt16(txtUser.Text), txtPwd.Text);
                    //DataTable dt = (DataTable)JsonConvert.DeserializeObject(client.buscarLogin(Convert.ToInt16(txtUser.Text), txtPwd.Text), typeof(DataTable));
                    //String permiso = dt.Rows[8].ToString();
                    String permiso = cadena.Substring(cadena.Length - 3, 1);
                    if (cadena != "[]")
                    {
                        FormMenuPrincipal formMenuPrincipal = new FormMenuPrincipal();
                        FormLateral       formLat           = new FormLateral();
                        formMenuPrincipal.Show();
                        if (permiso == "0")
                        {
                            formMenuPrincipal.btnUsers.Enabled         = false;
                            formMenuPrincipal.btnUsers.BackColor       = Color.Gray;
                            formMenuPrincipal.btnProveedores.Enabled   = false;
                            formMenuPrincipal.btnProveedores.BackColor = Color.Gray;

                            formLat.btnUsers.Enabled         = false;
                            formLat.btnUsers.BackColor       = Color.Gray;
                            formLat.btnProveedores.Enabled   = false;
                            formLat.btnProveedores.BackColor = Color.Gray;
                        }
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Id de usuario o contraseña incorrectos.");
                        txtPwd.Text  = "";
                        txtUser.Text = "";
                    }
                }
                catch
                {
                    MessageBox.Show("No sirvio :(");
                }
            }
        }
示例#11
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text != "" && txtApellidos.Text != "" && txtDireccion.Text != "" && txtNacimiento.Text != "" && txtTelefono.Text != "" && txtCorreo.Text != "" && txtPassword.Text != "" && comboBox1.Text != "")
            {
                if (MessageBox.Show("¿Esta seguro Agregar este Usuario al sistema?", "Salir", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    Usuario json = new Usuario();
                    json.nombre   = txtNombre.Text;
                    json.apellido = txtApellidos.Text;

                    json.fecha_nacimiento = txtNacimiento.Text;
                    json.direccion        = txtDireccion.Text;
                    json.telefono         = txtTelefono.Text;
                    json.correo           = txtCorreo.Text;
                    json.password         = txtPassword.Text;
                    json.permiso          = comboBox1.SelectedIndex;
                    data   = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented) + "]";
                    data2 += data;

                    using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
                    {
                        try
                        {
                            client.altaUsuario(data2);
                            MessageBox.Show("Usuario Insertado! :)");
                            data  = "";
                            data2 = "[";
                            ActualizarTabla();
                        }
                        catch
                        {
                            MessageBox.Show("No sirvio :(");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Por favor llena todos los campos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#12
0
        private void FormProveedores_Load(object sender, EventArgs e)
        {
            FormLateral frmLat = new FormLateral();

            frmLat.TopLevel = false;
            frmLat.Parent   = panel1;
            frmLat.Show();
            frmLat.BringToFront();
            using (ServiceReference1.ServidorWebClient client = new ServiceReference1.ServidorWebClient())
            {
                try
                {
                    DataTable dt = (DataTable)JsonConvert.DeserializeObject(client.cargarProveedor(), typeof(DataTable));

                    dgvTabla.DataSource = dt;
                }
                catch
                {
                    MessageBox.Show("No sirvio :(");
                }
            }
            Globales.f = "Proveedores";
        }