Beispiel #1
0
        private void btnSearchProduct_Click(object sender, EventArgs e)
        {
            var frmCustomerSearchForm = new frmCustomerSearch();

            frmCustomerSearchForm.ShowDialog();
            SetCustomerValues();
        }
Beispiel #2
0
        private void txtCliente_Leave(object sender, EventArgs e)
        {
            lblCodigoCliente.Text = string.Empty;

            if (txtCliente.Text != string.Empty)
            {
                string stringSQL = "c.cliente_id AS Codigo, " +
                                   "c.Tipo_documento AS [Tipo documento], " +
                                   "c.Documento, " +
                                   "IIf(c.Tipo_documento='RUC',c.cliente_apellidos,c.cliente_apellidos+', '+c.cliente_nombres) AS Cliente," +
                                   "c.Cliente_direccion AS Direccion, " +
                                   "c.Telefono_casa AS [Telefono fijo], " +
                                   "c.Telefono_celular AS Celular, " +
                                   "c.Telefono_trabajo AS [Telefono trabajo], " +
                                   "c.Email_principal AS [Email Principal]," +
                                   "c.Comentario, " +
                                   "c.Fecha_creacion AS [Fecha creacion], " +
                                   "cr.Apellidos_empleado+', '+cr.Nombres_empleado AS [Creado por]," +
                                   "c.Fecha_actualizacion AS [Fecha actualizacion]," +
                                   "up.Apellidos_empleado+', '+up.Nombres_empleado AS [Actualizado por]" +
                                   "  FROM (cliente AS c LEFT JOIN empleado AS cr ON c.creado_por=cr.codigo_empleado)" +
                                   "  LEFT JOIN empleado AS up ON c.actualizado_por=up.codigo_empleado";

                string stringWhere = string.Empty;

                DataSet dsSearch = DataUtil.FillDataSet("SELECT " + stringSQL + " WHERE c.cliente_apellidos like '%" + txtCliente.Text.Trim().Replace("'", "''") + "%'" + stringWhere + " ORDER BY c.cliente_apellidos", "cliente");
                if (dsSearch.Tables[0].Rows.Count == 1)
                {
                    txtCliente.Text       = DataUtil.GetString(dsSearch.Tables[0].Rows[0], "Cliente");
                    lblCodigoCliente.Text = DataUtil.GetString(dsSearch.Tables[0].Rows[0], "Codigo");
                }
                else if (dsSearch.Tables[0].Rows.Count > 1)
                {
                    var frmCustomerSearchForm = new frmCustomerSearch();
                    frmCustomerSearchForm.ApellidoSearch  = txtCliente.Text;
                    frmCustomerSearchForm.DsSearchCliente = dsSearch;
                    frmCustomerSearchForm.ShowDialog();
                    SetCustomerValues();
                }
                else
                {
                    MessageBox.Show(@"No existe el cliente.", @"Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtCliente.Text       = string.Empty;
                    lblCodigoCliente.Text = string.Empty;
                    txtCliente.Focus();
                }
            }
        }
Beispiel #3
0
        private void txtCliente_Leave(object sender, EventArgs e)
        {
            lblCodigoCliente.Text = string.Empty;
            lblNombreCliente.Text = string.Empty;
            txtDireccion.Text     = string.Empty;

            if (txtNumeroCliente.Text != string.Empty)
            {
                string stringSQL = "c.cliente_id AS Codigo, " +
                                   "c.Tipo_documento AS [Tipo documento], " +
                                   "c.Documento, " +
                                   "IIf(c.Tipo_documento='RUC',c.cliente_apellidos,c.cliente_apellidos+', '+c.cliente_nombres) AS Cliente," +
                                   "c.Cliente_direccion AS Direccion, " +
                                   "c.Telefono_casa AS [Telefono fijo], " +
                                   "c.Telefono_celular AS Celular, " +
                                   "c.Telefono_trabajo AS [Telefono trabajo], " +
                                   "c.Email_principal AS [Email Principal]," +
                                   "c.Comentario, " +
                                   "c.Fecha_creacion AS [Fecha creacion], " +
                                   "cr.Apellidos_empleado+', '+cr.Nombres_empleado AS [Creado por]," +
                                   "c.Fecha_actualizacion AS [Fecha actualizacion]," +
                                   "up.Apellidos_empleado+', '+up.Nombres_empleado AS [Actualizado por]" +
                                   "  FROM (cliente AS c LEFT JOIN empleado AS cr ON c.creado_por=cr.codigo_empleado)" +
                                   "  LEFT JOIN empleado AS up ON c.actualizado_por=up.codigo_empleado";

                DataSet dsSearch = DataUtil.FillDataSet("SELECT " + stringSQL + " WHERE c.Telefono_casa like '%" + txtNumeroCliente.Text.Trim() + "%' ORDER BY c.cliente_apellidos", "cliente");
                if (dsSearch.Tables[0].Rows.Count == 1)
                {
                    txtNumeroCliente.Text = DataUtil.GetString(dsSearch.Tables[0].Rows[0], "Telefono fijo");
                    lblCodigoCliente.Text = DataUtil.GetString(dsSearch.Tables[0].Rows[0], "Codigo");
                    lblNombreCliente.Text = DataUtil.GetString(dsSearch.Tables[0].Rows[0], "Cliente");
                    txtDireccion.Text     = DataUtil.GetString(dsSearch.Tables[0].Rows[0], "Direccion");
                }
                else if (dsSearch.Tables[0].Rows.Count > 1)
                {
                    var frmCustomerSearchForm = new frmCustomerSearch();
                    frmCustomerSearchForm.NumberoTelefonoSearch = txtNumeroCliente.Text;
                    frmCustomerSearchForm.DsSearchCliente       = dsSearch;
                    frmCustomerSearchForm.ShowDialog();
                    SetCustomerValues();
                }
                else
                {
                    DialogResult result = MessageBox.Show(@"No existe el cliente. Desea crear el cliente?", @"Cliente", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        var frmCustomerAdd = new frmCustomer();
                        frmCustomerAdd.adding                = true;
                        frmCustomerAdd.CreateSpecial         = true;
                        frmCustomerAdd.ClienteNumeroTelefono = txtNumeroCliente.Text.Trim();
                        frmCustomerAdd.formTitle             = "Cliente - Agregar";
                        frmCustomerAdd.ShowDialog();
                        SetCustomerValues();
                    }
                    else
                    {
                        txtNumeroCliente.Text = string.Empty;
                        txtNumeroCliente.Focus();
                    }
                }
            }
        }