Exemple #1
0
        private void TxtClientId_TextChanged(object sender, EventArgs e)
        {
            txtClientName.Clear();
            bool request = clientLog.Read_once_exist(txtClientId.Text);

            if (request)
            {
                LblClientIdMsj.Text = "";
                Client client = clientLog.Read_once(txtClientId.Text);
                txtClientName.Text = client.Client_name;
            }
            else
            {
                LblClientIdMsj.Text = "No se encuentra";
            }
            if (txtClientId.Text.Equals(""))
            {
                LblClientIdMsj.Text = "";
            }
        }
Exemple #2
0
        private void DgvClient_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (DgvClient.CurrentCell.GetType().ToString() == "System.Windows.Forms.DataGridViewButtonCell")
                {
                    if (orderLog.ClientOrders(DgvClient.Rows[e.RowIndex].Cells[0].Value.ToString()) == 0)
                    {
                        DialogResult dr = MessageBox.Show("¿Está seguro de eliminar el cliente " +
                                                          Environment.NewLine +
                                                          DgvClient.Rows[e.RowIndex].Cells[0].Value.ToString() + " | " +
                                                          DgvClient.Rows[e.RowIndex].Cells[1].Value.ToString() + "?", "Mensaje",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr == DialogResult.Yes)
                        {
                            //Eliminamos
                            clientLog.Delete(DgvClient.Rows[e.RowIndex].Cells[0].Value.ToString());
                            //habilita botones
                            IbtnCreate.Text = "Crear";
                            //Limpiamos campos
                            CleanFieldsN();
                            CleanFieldsJ();
                            //Cargamos los deptos
                            LoadCboDpts();
                            //Actualizamos tabla
                            IbtnRefresh_Click(sender, e);
                            IbtnNew_Click(null, e);
                        }
                    }
                    else
                    {
                        MessageBox.Show(DgvClient, "El cliente no se puede eliminar porque tiene órdenes a su nombre",
                                        "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    //Console.WriteLine("Eliminar "+ DgvClient.Rows[e.RowIndex].Cells[0].Value.ToString());
                }
                else
                {
                    Console.WriteLine("Ver datos en form");
                    //Cambiamos el ícono
                    this.IbtnCreate.IconChar = FontAwesome.Sharp.IconChar.Edit;
                    IbtnCreate.Text          = "Editar";
                    IbtnNew.Enabled          = true;
                    //Consultamos el cliente para saber el tipo(Se puede hace funcion que traiga el char j o n
                    Client client = clientLog.Read_once(DgvClient.Rows[e.RowIndex].Cells[0].Value.ToString());
                    //Si tipo J->mostramos el formulario de cliente juridico
                    if (client.Client_type.Equals('j'))
                    {
                        //Estado interno del boton Crear
                        stateButtonJ = "Editar";
                        //Inhabilitamos controles para ver la informacion solamente
                        InactiveFieldsClientJ();
                        //Cambiamos el tipo a jurídico
                        cboTypeClient.SelectedIndex = 0;
                        gpJuridic.BringToFront();
                        //Cargamos el formulario
                        txtNit.Text       = client.Client_id;
                        txtRut.Text       = client.Client_rut;
                        txtTradename.Text = client.Client_name;
                        cboLestruct.Text  = client.Client_lstructure;
                        txtRlegal.Text    = client.Client_rlegal;
                        txtAdmin.Text     = client.Client_adm;
                        txtTel1.Text      = client.Client_tel1;
                        txtFax.Text       = client.Client_fax;
                        txtWebsite.Text   = client.Client_website;
                        cboDptoJ.Text     = client.Client_department;
                        cboCityJ.Text     = client.Client_city;
                        txtAddresJ.Text   = client.Client_address;
                        txtLocationJ.Text = client.Client_location;
                        txtEmailJ.Text    = client.Client_email;
                        txtTel2.Text      = client.Client_tel2;
                    }
                    //Si tipo N->mostramos el formulario de cliente natural
                    else if (client.Client_type.Equals('n'))
                    {
                        stateButtonN = "Editar";
                        //Inhabilitamos los controles
                        InactiveFieldsClientN();
                        //Cambios el tipo a natural.
                        cboTypeClient.SelectedIndex = 1;
                        gpNatural.BringToFront();
                        //Cargamos la informacion en los campos
                        txtId.Text      = client.Client_id;
                        txtName.Text    = client.Client_name;
                        cboDptoN.Text   = client.Client_department;
                        cboCityN.Text   = client.Client_city;
                        txtAddresN.Text = client.Client_address;
                        txtTel.Text     = client.Client_tel1;
                        txtEmailN.Text  = client.Client_email;
                        txtId.ReadOnly  = true;
                    }
                }
                errorProvider1.Clear();
            }
        }