Beispiel #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    if (MessageBox.Show("¿Desea eliminar al cliente?", "Eliminar",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }

                    Entidades.ClienteModel _datosCliente = new Entidades.ClienteModel()
                    {
                        Id = int.Parse(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString())
                    };
                    string    inputJson = (new JavaScriptSerializer()).Serialize(_datosCliente);
                    WebClient client    = new WebClient();
                    client.Headers["Content-type"] = "application/json";
                    client.Encoding = Encoding.UTF8;
                    string json = client.UploadString(apiUrl + "/DeleteCliente", inputJson);

                    Refrescar_Grid();
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un elelemento");
                }
            }
            else
            {
                MessageBox.Show("No existen elementos en la grilla");
            }
        }
Beispiel #2
0
        public bool ActualizarCliente(Entidades.ClienteModel _cliente)
        {
            objBusinessLogic = new Class_Library.Cls_Handler_ClientesBD();

            objBusinessLogic.mtd_Update_Cliente(_cliente);

            return(true);
        }
Beispiel #3
0
        public bool DeleteCliente(Entidades.ClienteModel _cliente)
        {
            objBusinessLogic = new Class_Library.Cls_Handler_ClientesBD();

            objBusinessLogic.mtd_Eliminar_Cliente(_cliente.Id);

            return(true);
        }
Beispiel #4
0
        public ActionResult Delete(Entidades.ClienteModel datosClientes)
        {
            _objBusinessLogic = new Class_Library.Cls_Handler_ClientesBD();

            _objBusinessLogic.mtd_Eliminar_Cliente(datosClientes.Id);

            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public ActionResult Edit(Entidades.ClienteModel datosCliente)
        {
            _objBusinessLogic = new Class_Library.Cls_Handler_ClientesBD();

            _objBusinessLogic.mtd_Update_Cliente(datosCliente);

            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count > 0)
            {
                if (dataGridView1.SelectedRows.Count > 0)
                {
                    Entidades.ClienteModel _datosCliente = new Entidades.ClienteModel()
                    {
                        Id = int.Parse(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString())
                    };
                    string    inputJson = (new JavaScriptSerializer()).Serialize(_datosCliente);
                    WebClient client    = new WebClient();
                    client.Headers["Content-type"] = "application/json";
                    client.Encoding = Encoding.UTF8;
                    string json = client.UploadString(apiUrl + "/GetClienteById", inputJson);

                    var outputDTO = (new JavaScriptSerializer()).Deserialize <Entidades.ClienteModel>(json);

                    txttipodocumento.Text = outputDTO.Tipo_documento;
                    txtnrodocumento.Text  = outputDTO.Nro_documento;
                    txtnombre.Text        = outputDTO.Nombre;
                    txtdireccion.Text     = outputDTO.Direccion;
                    txttelefono.Text      = outputDTO.Telefono;
                    txtcorreo.Text        = outputDTO.Correo;
                    txtestado.Text        = outputDTO.Estados;

                    _idActualizarCliente = outputDTO.Id;

                    btnGuardar.Visible       = false;
                    btnEditar.Visible        = false;
                    btnEditarCliente.Visible = true;
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un elelemento");
                }
            }
            else
            {
                MessageBox.Show("No existen elementos en la grilla");
            }
        }
Beispiel #7
0
        public bool mtd_Insertar_Cliente(Entidades.ClienteModel datosInsertar)
        {
            bool resultado = true;

            getConnection();

            _objCommand             = new SqlCommand("SP_INSERTAR_CLIENTE", _objConexion);
            _objCommand.CommandType = CommandType.StoredProcedure;

            _objCommand.Parameters.Add("@tipo_documento", SqlDbType.VarChar).Value = datosInsertar.Tipo_documento;
            _objCommand.Parameters.Add("@nro_documento", SqlDbType.VarChar).Value  = datosInsertar.Nro_documento;
            _objCommand.Parameters.Add("@nombre_cliente", SqlDbType.VarChar).Value = datosInsertar.Nombre;
            _objCommand.Parameters.Add("@direccion", SqlDbType.VarChar).Value      = datosInsertar.Direccion;
            _objCommand.Parameters.Add("@telefono", SqlDbType.VarChar).Value       = datosInsertar.Telefono;
            _objCommand.Parameters.Add("@correo", SqlDbType.VarChar).Value         = datosInsertar.Correo;
            _objCommand.Parameters.Add("@estatus", SqlDbType.VarChar).Value        = datosInsertar.Estados;

            _objConexion.Open();
            _objCommand.ExecuteNonQuery();
            _objConexion.Close();

            return(resultado);
        }
Beispiel #8
0
        public void InsertCliente(Entidades.ClienteModel _cliente)
        {
            objBusinessLogic = new Class_Library.Cls_Handler_ClientesBD();

            objBusinessLogic.mtd_Insertar_Cliente(_cliente);
        }
Beispiel #9
0
        public Entidades.ClienteModel GetClienteById(Entidades.ClienteModel _cliente)
        {
            objBusinessLogic = new Class_Library.Cls_Handler_ClientesBD();

            return(objBusinessLogic.Obtener_Clientes().Find(lsmodel => lsmodel.Id == _cliente.Id));
        }
Beispiel #10
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txttipodocumento.Text.Length <= 10)
            {
                if (txtnrodocumento.Text.Length <= 20)
                {
                    if (txtnombre.Text.Length <= 255)
                    {
                        if (txtdireccion.Text.Length <= 255)
                        {
                            if (txttelefono.Text.Length <= 100)
                            {
                                if (txtcorreo.Text.Length <= 255)
                                {
                                    if (txtestado.Text.Length == 1)
                                    {
                                        Entidades.ClienteModel _datosCliente = new Entidades.ClienteModel()
                                        {
                                            Tipo_documento = txttipodocumento.Text,
                                            Nro_documento  = txtnrodocumento.Text,
                                            Nombre         = txtnombre.Text,
                                            Direccion      = txtdireccion.Text,
                                            Telefono       = txttelefono.Text,
                                            Correo         = txtcorreo.Text,
                                            Estados        = txtestado.Text
                                        };

                                        string    inputJson = (new JavaScriptSerializer()).Serialize(_datosCliente);
                                        WebClient client    = new WebClient();
                                        client.Headers["Content-type"] = "application/json";
                                        client.Encoding = Encoding.UTF8;
                                        string json = client.UploadString(apiUrl + "/InsertCliente", inputJson);
                                        Refrescar_Grid();
                                        Limpiar_Campos();
                                    }
                                    else
                                    {
                                        MessageBox.Show("El estado puede tener un maximo de 1 caracter");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("El correo puede tener un maximo de 255 caracteres");
                                }
                            }
                            else
                            {
                                MessageBox.Show("El telefono puede tener un maximo de 100 caracteres");
                            }
                        }
                        else
                        {
                            MessageBox.Show("La direccion puede tener un maximo de 255 caracteres");
                        }
                    }
                    else
                    {
                        MessageBox.Show("El nombre puede tener un maximo de 255 caracteres");
                    }
                }
                else
                {
                    MessageBox.Show("El nro de documento puede tener un maximo de 20 caracteres");
                }
            }
            else
            {
                MessageBox.Show("El tipo de documento puede tener un maximo de 10 caracteres");
            }
        }