Example #1
0
 public static RegistroClientes Instance()
 {
     if (frm == null)
     {
         frm = new RegistroClientes();
     }
     return(frm);
 }
Example #2
0
 private void lblClientes_LinkClicked(object sender, EventArgs e)
 {
     rc             = RegistroClientes.Instance();
     rc.MdiParent   = this;
     rc.WindowState = FormWindowState.Normal;
     rc.Show();
     rc.WindowState = FormWindowState.Maximized;
     rc.Show();
     rc.Activate();
 }
        private void ClienteModificar_FormClosing(object sender, FormClosingEventArgs e)
        {
            p = (Padre)this.MdiParent;
            RegistroClientes rc = null;

            rc           = RegistroClientes.Instance();
            rc.MdiParent = p;
            rc.Show();
            rc.Activate();
            rc.WindowState = FormWindowState.Maximized;
            this.Dispose();
        }
        private void btnModificar_Click(object sender, EventArgs e)
        {
            CLIENTE c        = new CLIENTE();
            string  rut      = lblMRut.Text;
            string  rutsindv = null;
            string  dv       = null;

            if (rut.Length == 12)
            {
                rutsindv = rut.Substring(0, 10).Replace(".", string.Empty).Trim();
                dv       = rut.Substring(11, 1).Trim();
            }
            else if (rut.Length == 11)
            {
                rutsindv = rut.Substring(0, 9).Replace(".", string.Empty).Trim();
                dv       = rut.Substring(10, 1).Trim();
            }
            try
            {
                if (txtMDireccion.Text.Length == 0)
                {
                    KryptonMessageBox.Show("CAMPO DE DIRECCIÓN ESTA VACÍO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (txtMRazon.Text.Length == 0)
                    {
                        KryptonMessageBox.Show("CAMPO RAZÓN ESTA VACÍO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (txtMGiro.Text.Length == 0)
                        {
                            MessageBox.Show("CAMPO DE GIRO ESTA VACÍO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            //Dirección
                            c.direccion = txtMDireccion.Text;
                            //Giro
                            c.giro = txtMGiro.Text;
                            //Razon
                            c.razon = txtMRazon.Text;
                            if (c.ModificarCliente(rutsindv, dv))
                            {
                                MessageBox.Show(txtMRazon.Text + " Modificado");
                                lblMRut.ResetText();
                                txtMDireccion.Clear();
                                txtMGiro.Clear();
                                txtMRazon.Clear();
                                p = (Padre)this.MdiParent;
                                RegistroClientes rc = null;
                                rc           = RegistroClientes.Instance();
                                rc.MdiParent = p;
                                rc.Show();
                                rc.Activate();
                                this.Dispose();
                            }
                            else
                            {
                                MessageBox.Show("Error al guardar");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnCrear_Click(object sender, EventArgs e)
        {
            CLIENTE c = new CLIENTE();

            try
            {
                if (txtRut.Text.Length == 0)
                {
                    KryptonMessageBox.Show("CAMPO RUT ESTÁ VACÍO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (txtRazon.Text.Length == 0)
                    {
                        KryptonMessageBox.Show("CAMPO RAZÓN ESTÁ VACÍO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (txtGiro.Text.Length == 0)
                        {
                            KryptonMessageBox.Show("CAMPO GIRO ESTÁ VACÍO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            if (txtDireccion.Text.Length == 0)
                            {
                                KryptonMessageBox.Show("CAMPO DIRECCION ESTÁ VACÍO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                            else
                            {
                                if (!s.validarRut(txtRut.Text))
                                {
                                    KryptonMessageBox.Show("RUT INGRESADO NO ES VÁLIDO", "MENSAJE DE ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                else
                                {
                                    string rut      = txtRut.Text;
                                    string rutsindv = null;
                                    string dv       = null;
                                    if (rut.Length == 12)
                                    {
                                        rutsindv = rut.Substring(0, 10).Replace(".", string.Empty).Trim();
                                        dv       = rut.Substring(11, 1).Trim();
                                    }
                                    else if (rut.Length == 11)
                                    {
                                        rutsindv = rut.Substring(0, 9).Replace(".", string.Empty).Trim();
                                        dv       = rut.Substring(10, 1).Trim();
                                    }
                                    //Rut Cliente
                                    c.rut = Convert.ToInt32(rutsindv);
                                    //Dígito Verificador Cliente
                                    c.dv = dv;
                                    //Razón Cliente
                                    c.razon = txtRazon.Text;
                                    //Giro Cliente
                                    c.giro = txtGiro.Text;
                                    //Direccion
                                    c.direccion = txtDireccion.Text;
                                    //Seleccionar por defecto en 1
                                    c.seleccionar = 1;
                                    //Estado Cliente por defecto en 1 (Activo)
                                    c.estado = 1;
                                    if (c.CrearCliente())
                                    {
                                        MessageBox.Show("Cliente Creado");
                                        txtRut.ResetText();
                                        txtRazon.Clear();
                                        txtDireccion.Clear();
                                        txtGiro.Clear();
                                        p = (Padre)this.MdiParent;
                                        RegistroClientes rc = null;
                                        rc           = RegistroClientes.Instance();
                                        rc.MdiParent = p;
                                        rc.Show();
                                        rc.WindowState = FormWindowState.Maximized;
                                        rc.Activate();
                                        this.Dispose();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Error al guardar");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }