Beispiel #1
0
        // method for listing all customers.
        public static List<clientes> listAllCustomers()
        {
            List<clientes> list = new List<clientes>();
            using(SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand("SELECT * FROM customers INNER JOIN Cities ON customers.CityID = Cities.ID INNER JOIN CustomerStatus ON CustomerStatus.ID = customers.StatusId", con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    clientes pClientes = new clientes();
                    pClientes.ID = re["ID"].ToString();
                    pClientes.Nombre = re["name"].ToString();
                    pClientes.Apellido = re["lastname"].ToString();
                    pClientes.Cedula = re["idcard"].ToString();
                    pClientes.Image = re.GetString(5);
                    pClientes.Status = re["Status"].ToString();
                    pClientes.Fecha_Registro = re["registerdate"].ToString();
                    pClientes.Direccion = re["cAddress"].ToString();
                    pClientes.E_Mail = re["email"].ToString();
                    pClientes.Ocupacion = re["ocupation"].ToString();
                    pClientes.Sector = re["City"].ToString();
                    pClientes.Telefono = re["Phone"].ToString();
                    pClientes.Celular = re["Cellphone"].ToString();

                    list.Add(pClientes);
                }
                con.Close();
            }
            return list;
        }
Beispiel #2
0
        // when buscar button is clicked.
        private void btnSearchBuy_Click(object sender, EventArgs e)
        {
            frmCustomerSearch pComprador = new frmCustomerSearch();

            pComprador.type       = true;
            pComprador.Text       = "Buscar Comprador";
            pComprador.pGetStatus = "Comprador";
            pComprador.ShowDialog();
            if (pComprador.pCustSelectedID != null)
            {
                try
                {
                    if (clientes.getCustomerObject(pComprador.pCustSelectedID, "") != null)
                    {
                        clientes pClientes = clientes.getCustomerObject(pComprador.pCustSelectedID, "");
                        if (pClientes.Status == "Comprador")
                        {
                            cID                 = pClientes.ID;
                            pComprador1         = pClientes;
                            pbComprador.Image   = Image.FromFile(pClientes.Image);
                            txtIDBuy.Text       = pClientes.ID;
                            txtNameBuy.Text     = pClientes.Nombre;
                            txtLastNameBuy.Text = pClientes.Apellido;
                            if (Convert.ToInt32(clientes.verifyDocument(pComprador.pCustSelectedID, "")) <= 0)
                            {
                                rbCedulaCo.Checked = true;
                            }
                            else
                            {
                                rbPasaporteCo.Checked = true;
                            }
                            txtCedulaBuy.Text  = pClientes.Cedula;
                            txtCelularBuy.Text = pClientes.Celular;
                            txtPhoneBuy.Text   = pClientes.Telefono;
                        }
                        else
                        {
                            MessageBox.Show("No se ha seleccionado un comprador", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            btnSearchBuy.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No existe el comprador, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtIDBuy.Clear();
                        txtIDBuy.Focus();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("No se selecciono un comprador", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        // when buscar demandado button is clicked.
        private void btnSearchDemandado_Click(object sender, EventArgs e)
        {
            frmCustomerSearch pCustomer = new frmCustomerSearch();

            pCustomer.type       = true;
            pCustomer.Text       = "Busqueda Demandados";
            pCustomer.pGetStatus = "Demandado";
            pCustomer.ShowDialog();
            if (pCustomer.pCustSelectedID != null)
            {
                try
                {
                    if (clientes.getCustomerObject(pCustomer.pCustSelectedID, "") != null)
                    {
                        clientes pClientes = clientes.getCustomerObject(pCustomer.pCustSelectedID, "");
                        if (pClientes.Status == "Demandado")
                        {
                            pDemandado                 = pClientes;
                            cID2                       = pClientes.ID;
                            pbDemandado.Image          = Image.FromFile(pClientes.Image);
                            txtIDDemandado.Text        = pClientes.ID;
                            txtNameDemandado.Text      = pClientes.Nombre;
                            txtLastNameDemandado.Text  = pClientes.Apellido;
                            txtPhoneDemandado.Text     = pClientes.Telefono;
                            txtCellphoneDemandado.Text = pClientes.Celular;
                            if (Convert.ToInt32(clientes.verifyDocument(pCustomer.pCustSelectedID, "")) <= 0)
                            {
                                rbCedulaO.Checked = true;
                            }
                            else
                            {
                                rbPasaporteO.Checked = true;
                            }
                            txtCedulaDemandado.Text = pClientes.Cedula;
                        }
                        else
                        {
                            MessageBox.Show("El cliente no ha sido registrado como un demandado, seleccione uno diferente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            btnSearchDemandado.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("No existe el cliente, digite un id valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtIDDemandado.Clear();
                        txtIDDemandado.Focus();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("No se selecciono el Demandado, Intentelo nuevamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #4
0
        // when Buscar Inquilino is clicked.
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string ID, Cedula;

            if (string.IsNullOrEmpty(txtIDInqui.Text))
            {
                ID = "";
            }
            else
            {
                ID = txtIDInqui.Text;
            }
            if (txtCedulaIn.MaskCompleted)
            {
                Cedula = txtCedulaIn.Text;
            }
            else
            {
                Cedula = "";
            }
            if (clientes.getCustomerObject(txtIDInqui.Text, txtCedulaIn.Text) != null)
            {
                // assign the ID value to the variable.
                iID = txtIDInqui.Text;
                // load the customer.
                clientes pClientes = clientes.getCustomerObject(ID, Cedula);
                if (pClientes.Status == "Inquilino")
                {
                    pInquilino             = pClientes;
                    txtNameInqui.Text      = pClientes.Nombre;
                    pbInquilino.Image      = Image.FromFile(pClientes.Image);
                    txtLastNameInqui.Text  = pClientes.Apellido;
                    txtPhoneInqui.Text     = pClientes.Telefono;
                    txtCellphoneInqui.Text = pClientes.Celular;
                    if (Convert.ToInt32(clientes.verifyDocument(ID, Cedula)) <= 0)
                    {
                        rbCedulaIn.Checked = true;
                    }
                    else
                    {
                        rbPasaporteIn.Checked = true;
                    }
                    txtCedulaIn.Text = pClientes.Cedula;
                }
                else
                {
                    MessageBox.Show("El cliente seleccionado no ha sido clasificado correctamente, seleccione un Inquilino", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSearchInqui.Focus();
                }
            }
            else
            {
                MessageBox.Show("EL Inquilino no existe, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #5
0
        // when buscar label is clicked on clientes.
        private void lblSearchCust_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string ID, cedula;

            if (string.IsNullOrEmpty(txtCustID.Text))
            {
                ID = "";
            }
            else
            {
                ID = txtCustID.Text;
            }
            if (txtCedulaClie.MaskCompleted)
            {
                cedula = txtCedulaClie.Text;
            }
            else
            {
                cedula = "";
            }
            if (clientes.getCustomerObject(ID, cedula) != null)
            {
                // assign the ID value to the variable.
                cID = txtCustID.Text;
                // load the customer.
                clientes pClientes = clientes.getCustomerObject(ID, cedula);
                if (pClientes.Status == "Cliente")
                {
                    pCliente             = pClientes;
                    txtCustName.Text     = pClientes.Nombre;
                    pbCliente.Image      = Image.FromFile(pClientes.Image);
                    txtCustLastName.Text = pClientes.Apellido;
                    txtCustPhone.Text    = pClientes.Telefono;
                    txtCustCell.Text     = pClientes.Celular;
                    if (Convert.ToInt32(clientes.verifyDocument(ID, cedula)) <= 0)
                    {
                        rbCedulaCli.Checked = true;
                    }
                    else
                    {
                        rbPasaporteCli.Checked = true;
                    }
                    txtCedulaClie.Text = pCliente.Cedula;
                }
                else
                {
                    MessageBox.Show("El usuario a seleccionar no esta clasificado como cliente, digite otro ID", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSearchCustomer.Focus();
                }
            }
            else
            {
                MessageBox.Show("EL Cliente no existe, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #6
0
        // when buscar label is clicked on garante.
        private void lblSearchGara_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string ID, cedula;

            if (string.IsNullOrEmpty(txtIDGaran.Text))
            {
                ID = "";
            }
            else
            {
                ID = txtIDGaran.Text;
            }
            if (txtCedulaGa.MaskCompleted)
            {
                cedula = txtCedulaGa.Text;
            }
            else
            {
                cedula = "";
            }
            if (clientes.getCustomerObject(ID, cedula) != null)
            {
                // assign the ID value to the variable.
                gID = txtIDGaran.Text;
                // load the customer.
                clientes pClientes = clientes.getCustomerObject(ID, cedula);
                if (pClientes.Status == "Garante")
                {
                    pGarante               = pClientes;
                    txtNameGaran.Text      = pClientes.Nombre;
                    pbGarante.Image        = Image.FromFile(pClientes.Image);
                    txtLastNameGaran.Text  = pClientes.Apellido;
                    txtPhoneGaran.Text     = pClientes.Telefono;
                    txtCellphoneGaran.Text = pClientes.Celular;
                    if (Convert.ToInt32(clientes.verifyDocument(ID, cedula)) <= 0)
                    {
                        rbCedulaGa.Checked = true;
                    }
                    else
                    {
                        rbPasaporteGa.Checked = true;
                    }
                    txtCedulaGa.Text = pClientes.Cedula;
                }
                else
                {
                    MessageBox.Show("No se selecciono un garante, seleccione uno correcto de la lista", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSearchGaran.Focus();
                }
            }
            else
            {
                MessageBox.Show("EL Garante no existe, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #7
0
 // end of building constructs ///
 // method for registering customers.
 public static int customerRegistration(clientes pClientes, string image, string pasaporte)
 {
     int r = -1;
     using(SqlConnection con  = DBcomun.getConnection())
     {
         SqlCommand comand = new SqlCommand(string.Format("INSERT INTO customers (name, lastname, idcard, StatusId, picture, registerdate, cAddress, CityID, Phone, Cellphone, email, ocupation, pasaporte) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')",
             pClientes.Nombre, pClientes.Apellido, pClientes.Cedula, pClientes.Status, image, pClientes.Fecha_Registro, pClientes.Direccion, pClientes.Sector, pClientes.Telefono, pClientes.Celular, pClientes.E_Mail, pClientes.Ocupacion, pasaporte), con);
         r = comand.ExecuteNonQuery();
         con.Close();
     }
     return r;
 }
Beispiel #8
0
        // end of building constructs ///
        // method for registering customers.
        public static int customerRegistration(clientes pClientes, string image, string pasaporte)
        {
            int r = -1;

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand(string.Format("INSERT INTO customers (name, lastname, idcard, StatusId, picture, registerdate, cAddress, CityID, Phone, Cellphone, email, ocupation, pasaporte) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}')",
                                                                 pClientes.Nombre, pClientes.Apellido, pClientes.Cedula, pClientes.Status, image, pClientes.Fecha_Registro, pClientes.Direccion, pClientes.Sector, pClientes.Telefono, pClientes.Celular, pClientes.E_Mail, pClientes.Ocupacion, pasaporte), con);
                r = comand.ExecuteNonQuery();
                con.Close();
            }
            return(r);
        }
Beispiel #9
0
        // when buscar cliente is clicked.
        private void btnSearchCustomer_Click(object sender, EventArgs e)
        {
            frmCustomerSearch pc = new frmCustomerSearch();

            pc.type       = true;
            pc.Text       = "Busqueda de Clientes";
            pc.pGetStatus = "Cliente";
            pc.ShowDialog();

            if (pc.pCustSelectedID != null)
            {
                // assign the ID value to the variable.
                cID = pc.pCustSelectedID;
                // load the customer.
                clientes pClientes = clientes.getCustomerObject(pc.pCustSelectedID, "");
                if (pClientes.Status == "Cliente")
                {
                    pCliente             = pClientes;
                    txtCustID.Text       = pClientes.ID;
                    pbCliente.Image      = Image.FromFile(pClientes.Image);
                    txtCustName.Text     = pClientes.Nombre;
                    txtCustLastName.Text = pClientes.Apellido;
                    txtCustPhone.Text    = pClientes.Telefono;
                    txtCustCell.Text     = pClientes.Celular;
                    if (Convert.ToInt32(clientes.verifyDocument(pc.pCustSelectedID, "")) <= 0)
                    {
                        rbCedulaCli.Checked = true;
                    }
                    else
                    {
                        rbPasaporteCli.Checked = true;
                    }
                    txtCedulaClie.Text = pCliente.Cedula;
                }
                else
                {
                    MessageBox.Show("El cliente seleccionado no esta correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSearchCustomer.Focus();
                }
            }
            else
            {
                MessageBox.Show("NO se selecciono el cliente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #10
0
        private void btnSearchInqui_Click(object sender, EventArgs e)
        {
            frmCustomerSearch pSearch = new frmCustomerSearch();

            pSearch.type       = true;
            pSearch.Text       = "Busqueda de Inquilino";
            pSearch.pGetStatus = "Inquilino";
            pSearch.ShowDialog();
            if (pSearch.pCustSelectedID != null)
            {
                // assign the ID value to the variable.
                iID = pSearch.pCustSelectedID;
                // load the customer.
                clientes pClientes = clientes.getCustomerObject(pSearch.pCustSelectedID, "");
                if (pClientes.Status == "Inquilino")
                {
                    pInquilino             = pClientes;
                    txtIDInqui.Text        = pClientes.ID;
                    pbInquilino.Image      = Image.FromFile(pClientes.Image);
                    txtNameInqui.Text      = pClientes.Nombre;
                    txtLastNameInqui.Text  = pClientes.Apellido;
                    txtPhoneInqui.Text     = pClientes.Telefono;
                    txtCellphoneInqui.Text = pClientes.Celular;
                    if (Convert.ToInt32(clientes.verifyDocument(pSearch.pCustSelectedID, "")) <= 0)
                    {
                        rbCedulaIn.Checked = true;
                    }
                    else
                    {
                        rbPasaporteIn.Checked = true;
                    }
                    txtCedulaIn.Text = pClientes.Cedula;
                }
                else
                {
                    MessageBox.Show("El cliente no esta clasificado exitosamente, seleccione un Inquilino de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSearchInqui.Focus();
                }
            }
            else
            {
                MessageBox.Show("No se selecciono un inquilino", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #11
0
        // when buscar Garante is clicked.
        private void btnSearchGaran_Click(object sender, EventArgs e)
        {
            frmCustomerSearch pSearch = new frmCustomerSearch();

            pSearch.type       = true;
            pSearch.Text       = "Busqueda de Garantes";
            pSearch.pGetStatus = "Garante";
            pSearch.ShowDialog();
            if (pSearch.pCustSelectedID != null)
            {
                // assign the ID value to the variable.
                gID = pSearch.pCustSelectedID;
                // load the customer.
                clientes pClientes = clientes.getCustomerObject(pSearch.pCustSelectedID, "");
                if (pClientes.Status == "Garante")
                {
                    pGarante               = pClientes;
                    txtIDGaran.Text        = pClientes.ID;
                    pbGarante.Image        = Image.FromFile(pClientes.Image);
                    txtNameGaran.Text      = pClientes.Nombre;
                    txtLastNameGaran.Text  = pClientes.Apellido;
                    txtPhoneGaran.Text     = pClientes.Telefono;
                    txtCellphoneGaran.Text = pClientes.Celular;
                    if (Convert.ToInt32(clientes.verifyDocument(pSearch.pCustSelectedID, "")) <= 0)
                    {
                        rbCedulaGa.Checked = true;
                    }
                    else
                    {
                        rbPasaporteGa.Checked = true;
                    }
                    txtCedulaGa.Text = pClientes.Cedula;
                }
                else
                {
                    MessageBox.Show("No se ha seleccionado el garante", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSearchGaran.Focus();
                }
            }
        }
Beispiel #12
0
        // method for getting customers data.
        public static clientes getCustomerObject(string ID, string idCard)
        {
            clientes pClientes = new clientes();

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand    comand = new SqlCommand(string.Format("SELECT * FROM customers INNER JOIN Cities ON customers.CityID = Cities.ID INNER JOIN CustomerStatus ON CustomerStatus.ID = customers.StatusId WHERE customers.ID = '{0}' OR customers.idcard = '{1}'", ID, idCard), con);
                SqlDataReader re     = comand.ExecuteReader();
                if (re.HasRows)
                {
                    while (re.Read())
                    {
                        pClientes.ID             = re["ID"].ToString();
                        pClientes.Nombre         = re["name"].ToString();
                        pClientes.Apellido       = re["lastname"].ToString();
                        pClientes.Cedula         = re["idcard"].ToString();
                        pClientes.Image          = re.GetString(5);
                        pClientes.Status         = re["Status"].ToString();
                        pClientes.Fecha_Registro = re["registerdate"].ToString();
                        pClientes.Fecha_Registro = re["registerdate"].ToString();
                        pClientes.Direccion      = re["cAddress"].ToString();
                        pClientes.E_Mail         = re["email"].ToString();
                        pClientes.Ocupacion      = re["ocupation"].ToString();
                        pClientes.Sector         = re["City"].ToString();
                        pClientes.Telefono       = re["Phone"].ToString();
                        pClientes.Celular        = re["Cellphone"].ToString();
                    }
                }
                else
                {
                    pClientes = null;
                }
                con.Close();
            }
            return(pClientes);
        }
 // when Guardar button is clicked.
 private void btnSave_Click(object sender, EventArgs e)
 {
     // variable for evaluating cb for documents.
     bool validationStatus;
     // Input validation for users input.
     if(rbCedula.Checked)
     {
         if(!txtID.MaskCompleted)
         {
             MessageBox.Show("La cedula esta vacia, digite una valida", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txtID.Focus();
             validationStatus = false;
         }
         else
         {
             validationStatus = true;
         }
     }
     else
     {
         if(!txtPassport.MaskCompleted)
         {
             MessageBox.Show("El Pasaporte esta vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txtPassport.Focus();
             validationStatus = false;
         }
         else
         {
             validationStatus = true;
         }
     }
     if (txtName.Text == string.Empty)
     {
         MessageBox.Show("Nombre vacio, digite un numero", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtName.Focus();
     }
     else if (txtLastName.Text == string.Empty)
     {
         MessageBox.Show("Apellido vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtLastName.Focus();
     }
     else if (To == null)
     {
         MessageBox.Show("No se ha seleccionado una Imagen", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         btnSelectImage.Focus();
     }
     else if (txtAddress.Text == string.Empty)
     {
         MessageBox.Show("La direccion esta vacia, Digite una valida", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtAddress.Focus();
     }
     else if (!txtPhone.MaskCompleted)
     {
         MessageBox.Show("El telefono esta vacia", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtPhone.Focus();
     }
     else if (!txtCellphone.MaskCompleted)
     {
         MessageBox.Show("El Celular esta vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (txtEmail.Text == string.Empty)
     {
         MessageBox.Show("El E-mail esta vacio, digite uno valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtEmail.Focus();
     }
     else if (txtOcupation.Text == string.Empty)
     {
         MessageBox.Show("No se ha completado la Ocupacion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtOcupation.Focus();
     }
     else if (cbSector.Text == string.Empty)
     {
         MessageBox.Show("No se ha seleccionado un sector", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         cbSector.Focus();
     }
     else
     {
         // if all values are filled.
         if (validationStatus)
         {
             // fill all Objects Data.
             clientes c = new clientes();
             c.Nombre = txtName.Text;
             c.Apellido = txtLastName.Text;
             c.Fecha_Registro = DateTime.Now.Date.ToString("MM/dd/yyyy");
             c.Ocupacion = txtOcupation.Text;
             c.Telefono = txtPhone.Text;
             c.Celular = txtCellphone.Text;
             c.Direccion = txtAddress.Text;
             c.E_Mail = txtEmail.Text;
             // get Sector and Status ID
             try
             {
                 // execute method for getting CityID.
                 c.Sector = sectores.getCityID(cbSector.SelectedItem.ToString());
                 // execute method for getting Status ID.
                 c.Status = clientes.getStatusID(cbstatus.SelectedItem.ToString());
             }
             catch(Exception ex)
             {
                     MessageBox.Show(ex.Message, "Sectores", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             // verify which document will be used.
             if (rbCedula.Checked)
             {
                 if (txtID.Text != string.Empty) c.Cedula = txtID.Text;
             }
             else
             {
                 if (txtPassport.Text != string.Empty) c.Cedula = txtPassport.Text;
             }
             // make a try cacth extatement.
             try
             {
                 // validate result value.
                 // if result is true. all inputs are filled.
                 // verify if customer is already registered.
                 if ((clientes.verify(txtID.Text) && txtID.MaskCompleted) || (clientes.verify(txtPassport.Text) && txtPassport.MaskCompleted))
                 {
                     int pasaporte;
                     if(rbCedula.Checked == true)
                     {
                         pasaporte = 0;
                     }
                     else
                     {
                         pasaporte = 1;
                     }
                     // execute method for registering users.
                     if (clientes.customerRegistration(c, To, pasaporte.ToString()) > 0)
                     {
                         MessageBox.Show("Registrado Exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         File.Copy(From, To, true);
                         clearInputs();
                     }
                     else
                     {
                         MessageBox.Show("No se pudo registrar el Cliente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }
                 }
                 else
                 {
                     MessageBox.Show("El Cliente ya ha sido registrado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Beispiel #14
0
 // when seleccionar button is clicked.
 private void btnSeleccionar_Click(object sender, EventArgs e)
 {
     string ID = "", Servicio = "";
     if (dgvFacturacion.SelectedRows.Count == 1)
     {
         ID = dgvFacturacion.CurrentRow.Cells[0].Value.ToString();
         Servicio = dgvFacturacion.CurrentRow.Cells[1].Value.ToString();
         try {
             if (rbAlquiler.Checked == true)
             {
                 cleanInputs();
                 pBaseObjfactura = facturacion.getRentStatus(ID);
                 pCliente = clientes.getCustomerObject(pBaseObjfactura.Cliente_ID, "");
                 pService = servicios.getServiceInfo(pBaseObjfactura.Service_ID);
                 dbMensualidad.Checked = true;
                 gbPagoRealizar.Visible = true;
                 if(Convert.ToInt32(clientes.verifyDocument(pCliente.ID, "")) > 0)
                 {
                     rbPasaporte.Checked = true;
                 }
                 else
                 {
                     rbCedula.Checked = true;
                 }
                 txtCedula.Text = pCliente.Cedula;
                 txtNumeroCaso.Text = pBaseObjfactura.Case_ID;
                 txtServicio.Text = pService.Servicio;
                 pbCedula.Image = Image.FromFile(pCliente.Image);
                 if (pBaseObjfactura.fechaUltimoPago == string.Empty || pBaseObjfactura.fechaUltimoPago == null)
                 {
                     txtUltimoPago.Text = "No se ha hecho un pago aun";
                 }
                 else
                 {
                     txtUltimoPago.Text = Convert.ToDateTime(pBaseObjfactura.fechaUltimoPago).ToLongDateString();
                 }
                 gbParametrosBusqueda.Enabled = false;
             }
             else if (rbVentas.Checked == true)
             {
                 // ventas
                 cleanInputs();
                 pBaseObjfactura = facturacion.getVentasStatus(ID);
                 pCliente = clientes.getCustomerObject(pBaseObjfactura.Cliente_ID, "");
                 pService = servicios.getServiceInfo(pBaseObjfactura.Service_ID);
                 txtBalanceTotal.Text = pBaseObjfactura.TotalPago_Mensualidad;
                 if (Convert.ToInt32(clientes.verifyDocument(pCliente.ID, "")) > 0)
                 {
                     rbPasaporte.Checked = true;
                 }
                 else
                 {
                     rbCedula.Checked = true;
                 }
                 txtCedula.Text = pCliente.Cedula;
                 txtImpSobreRenta.Text = "Incluido";
                 txtITEBIS.Text = "Incluido";
                 txtNumeroCaso.Text = pBaseObjfactura.Case_ID;
                 txtServicio.Text = pService.Servicio;
                 txtTotalaPagar.Text = pBaseObjfactura.TotalPago_Mensualidad;
                 if (pBaseObjfactura.fechaUltimoPago == string.Empty || pBaseObjfactura.fechaUltimoPago == null)
                 {
                     txtUltimoPago.Text = "No se ha hecho un pago aun";
                 }
                 else
                 {
                     txtUltimoPago.Text = Convert.ToDateTime(pBaseObjfactura.fechaUltimoPago).ToLongDateString();
                 }
                 gbParametrosBusqueda.Enabled = false;
             }
             else if (rbDivorcioAccidente.Checked == true)
             {
                 // divorcios accidente
                 cleanInputs();
                 pBaseObjfactura = facturacion.getDivorciosAccidentesStatus(ID);
                 pCliente = clientes.getCustomerObject(pBaseObjfactura.Cliente_ID, "");
                 pService = servicios.getServiceInfo(pBaseObjfactura.Service_ID);
                 txtBalanceTotal.Text = pBaseObjfactura.TotalPago_Mensualidad;
                 if (Convert.ToInt32(clientes.verifyDocument(pCliente.ID, "")) > 0)
                 {
                     rbPasaporte.Checked = true;
                 }
                 else
                 {
                     rbCedula.Checked = true;
                 }
                 txtCedula.Text = pCliente.Cedula;
                 txtImpSobreRenta.Text = "Incluido";
                 txtITEBIS.Text = "Incluido";
                 txtNumeroCaso.Text = pBaseObjfactura.Case_ID;
                 txtServicio.Text = pService.Servicio;
                 txtTotalaPagar.Text = pBaseObjfactura.TotalPago_Mensualidad;
                 if (pBaseObjfactura.fechaUltimoPago == string.Empty || pBaseObjfactura.fechaUltimoPago == null)
                 {
                     txtUltimoPago.Text = "No se ha hecho un pago aun";
                 }
                 else
                 {
                     txtUltimoPago.Text = Convert.ToDateTime(pBaseObjfactura.fechaUltimoPago).ToLongDateString();
                 }
                 gbParametrosBusqueda.Enabled = false;
             }
             else
             {
                 // general is selected.
                 if(Servicio == "Alquiler")
                 {
                     // alquiler
                     cleanInputs();
                     pBaseObjfactura = facturacion.getRentStatus(ID);
                     pCliente = clientes.getCustomerObject(pBaseObjfactura.Cliente_ID, "");
                     pService = servicios.getServiceInfo(pBaseObjfactura.Service_ID);
                     dbMensualidad.Checked = true;
                     gbPagoRealizar.Visible = true;
                     if (Convert.ToInt32(clientes.verifyDocument(pCliente.ID, "")) > 0)
                     {
                         rbPasaporte.Checked = true;
                     }
                     else
                     {
                         rbCedula.Checked = true;
                     }
                     txtCedula.Text = pCliente.Cedula;
                     txtNumeroCaso.Text = pBaseObjfactura.Case_ID;
                     txtServicio.Text = pService.Servicio;
                     pbCedula.Image = Image.FromFile(pCliente.Image);
                     if (pBaseObjfactura.fechaUltimoPago == string.Empty || pBaseObjfactura.fechaUltimoPago == null)
                     {
                         txtUltimoPago.Text = "No se ha hecho un pago aun";
                     }
                     else
                     {
                         txtUltimoPago.Text = Convert.ToDateTime(pBaseObjfactura.fechaUltimoPago).ToLongDateString();
                     }
                     rbAlquiler.Checked = true;
                     gbParametrosBusqueda.Enabled = false;
                 }
                 else if(Servicio == "Divorcio o Accidente")
                 {
                     // Divorcio accidente.
                     cleanInputs();
                     pBaseObjfactura = facturacion.getDivorciosAccidentesStatus(ID);
                     pCliente = clientes.getCustomerObject(pBaseObjfactura.Cliente_ID, "");
                     pService = servicios.getServiceInfo(pBaseObjfactura.Service_ID);
                     txtBalanceTotal.Text = pBaseObjfactura.TotalPago_Mensualidad;
                     if (Convert.ToInt32(clientes.verifyDocument(pCliente.ID, "")) > 0)
                     {
                         rbPasaporte.Checked = true;
                     }
                     else
                     {
                         rbCedula.Checked = true;
                     }
                     txtCedula.Text = pCliente.Cedula;
                     txtImpSobreRenta.Text = "Incluido";
                     txtITEBIS.Text = "Incluido";
                     txtNumeroCaso.Text = pBaseObjfactura.Case_ID;
                     txtServicio.Text = pService.Servicio;
                     txtTotalaPagar.Text = pBaseObjfactura.TotalPago_Mensualidad;
                     if (pBaseObjfactura.fechaUltimoPago == string.Empty || pBaseObjfactura.fechaUltimoPago == null)
                     {
                         txtUltimoPago.Text = "No se ha hecho un pago aun";
                     }
                     else
                     {
                         txtUltimoPago.Text = Convert.ToDateTime(pBaseObjfactura.fechaUltimoPago).ToLongDateString();
                     }
                     rbDivorcioAccidente.Checked = true;
                     gbParametrosBusqueda.Enabled = false;
                 }
                 else if (Servicio == "Ventas de Inmuebles")
                 {
                     // venta
                     cleanInputs();
                     pBaseObjfactura = facturacion.getVentasStatus(ID);
                     pCliente = clientes.getCustomerObject(pBaseObjfactura.Cliente_ID, "");
                     pService = servicios.getServiceInfo(pBaseObjfactura.Service_ID);
                     txtBalanceTotal.Text = pBaseObjfactura.TotalPago_Mensualidad;
                     if (Convert.ToInt32(clientes.verifyDocument(pCliente.ID, "")) > 0)
                     {
                         rbPasaporte.Checked = true;
                     }
                     else
                     {
                         rbCedula.Checked = true;
                     }
                     txtCedula.Text = pCliente.Cedula;
                     txtImpSobreRenta.Text = "Incluido";
                     txtITEBIS.Text = "Incluido";
                     txtNumeroCaso.Text = pBaseObjfactura.Case_ID;
                     txtServicio.Text = pService.Servicio;
                     txtTotalaPagar.Text = pBaseObjfactura.TotalPago_Mensualidad;
                     if (pBaseObjfactura.fechaUltimoPago == string.Empty || pBaseObjfactura.fechaUltimoPago == null)
                     {
                         txtUltimoPago.Text = "No se ha hecho un pago aun";
                     }
                     else
                     {
                         txtUltimoPago.Text = Convert.ToDateTime(pBaseObjfactura.fechaUltimoPago).ToLongDateString();
                     }
                     rbVentas.Checked = true;
                     gbParametrosBusqueda.Enabled = false;
                 }
             }
         }
         catch(Exception ex)
         {
             MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("No se ha seleccionado un caso de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Beispiel #15
0
        // when label buscar is clicked on Demandado.
        private void lblSearchDemandante_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string ID, cedula;

            // verify if the id is empty.
            if (txtIDDemandante.Text == string.Empty)
            {
                ID = "";
            }
            else
            {
                ID = txtIDDemandante.Text;
            }
            if (txtCedulaDemandante.MaskCompleted)
            {
                cedula = txtCedulaDemandante.Text;
            }
            else
            {
                cedula = "";
            }
            try
            {
                if (clientes.getCustomerObject(ID, cedula) != null)
                {
                    clientes pClientes = clientes.getCustomerObject(ID, cedula);
                    if (pClientes.Status == "Demandante")
                    {
                        cID1                        = pClientes.ID;
                        pDemandante                 = pClientes;
                        pbDemandante.Image          = Image.FromFile(pClientes.Image);
                        txtNameDemandante.Text      = pClientes.Nombre;
                        txtLastNameDemandante.Text  = pClientes.Apellido;
                        txtPhoneDemandante.Text     = pClientes.Telefono;
                        txtCellphoneDemandante.Text = pClientes.Celular;
                        if (Convert.ToInt32(clientes.verifyDocument(ID, cedula)) <= 0)
                        {
                            rbCedulaE.Checked = true;
                        }
                        else
                        {
                            rbPasaporteE.Checked = true;
                        }
                        txtCedulaDemandante.Text = pClientes.Cedula;
                    }
                    else
                    {
                        MessageBox.Show("El cliente no se ha seleccionado como un demandante, seleccione uno valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        btnSearchDemandante.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("El cliente no existe, digite un id valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtIDDemandante.Clear();
                    txtIDDemandante.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        // when Guardar button is clicked.
        private void btnSave_Click(object sender, EventArgs e)
        {
            // variable for evaluating cb for documents.
            bool validationStatus;

            // Input validation for users input.
            if (rbCedula.Checked)
            {
                if (!txtID.MaskCompleted)
                {
                    MessageBox.Show("La cedula esta vacia, digite una valida", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtID.Focus();
                    validationStatus = false;
                }
                else
                {
                    validationStatus = true;
                }
            }
            else
            {
                if (!txtPassport.MaskCompleted)
                {
                    MessageBox.Show("El Pasaporte esta vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtPassport.Focus();
                    validationStatus = false;
                }
                else
                {
                    validationStatus = true;
                }
            }
            if (txtName.Text == string.Empty)
            {
                MessageBox.Show("Nombre vacio, digite un numero", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtName.Focus();
            }
            else if (txtLastName.Text == string.Empty)
            {
                MessageBox.Show("Apellido vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtLastName.Focus();
            }
            else if (To == null)
            {
                MessageBox.Show("No se ha seleccionado una Imagen", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                btnSelectImage.Focus();
            }
            else if (txtAddress.Text == string.Empty)
            {
                MessageBox.Show("La direccion esta vacia, Digite una valida", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtAddress.Focus();
            }
            else if (!txtPhone.MaskCompleted)
            {
                MessageBox.Show("El telefono esta vacia", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtPhone.Focus();
            }
            else if (!txtCellphone.MaskCompleted)
            {
                MessageBox.Show("El Celular esta vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtEmail.Text == string.Empty)
            {
                MessageBox.Show("El E-mail esta vacio, digite uno valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtEmail.Focus();
            }
            else if (txtOcupation.Text == string.Empty)
            {
                MessageBox.Show("No se ha completado la Ocupacion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtOcupation.Focus();
            }
            else if (cbSector.Text == string.Empty)
            {
                MessageBox.Show("No se ha seleccionado un sector", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cbSector.Focus();
            }
            else
            {
                // if all values are filled.
                if (validationStatus)
                {
                    // fill all Objects Data.
                    clientes c = new clientes();
                    c.Nombre         = txtName.Text;
                    c.Apellido       = txtLastName.Text;
                    c.Fecha_Registro = DateTime.Now.Date.ToString("MM/dd/yyyy");
                    c.Ocupacion      = txtOcupation.Text;
                    c.Telefono       = txtPhone.Text;
                    c.Celular        = txtCellphone.Text;
                    c.Direccion      = txtAddress.Text;
                    c.E_Mail         = txtEmail.Text;
                    // get Sector and Status ID
                    try
                    {
                        // execute method for getting CityID.
                        c.Sector = sectores.getCityID(cbSector.SelectedItem.ToString());
                        // execute method for getting Status ID.
                        c.Status = clientes.getStatusID(cbstatus.SelectedItem.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Sectores", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    // verify which document will be used.
                    if (rbCedula.Checked)
                    {
                        if (txtID.Text != string.Empty)
                        {
                            c.Cedula = txtID.Text;
                        }
                    }
                    else
                    {
                        if (txtPassport.Text != string.Empty)
                        {
                            c.Cedula = txtPassport.Text;
                        }
                    }
                    // make a try cacth extatement.
                    try
                    {
                        // validate result value.
                        // if result is true. all inputs are filled.
                        // verify if customer is already registered.
                        if ((clientes.verify(txtID.Text) && txtID.MaskCompleted) || (clientes.verify(txtPassport.Text) && txtPassport.MaskCompleted))
                        {
                            int pasaporte;
                            if (rbCedula.Checked == true)
                            {
                                pasaporte = 0;
                            }
                            else
                            {
                                pasaporte = 1;
                            }
                            // execute method for registering users.
                            if (clientes.customerRegistration(c, To, pasaporte.ToString()) > 0)
                            {
                                MessageBox.Show("Registrado Exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                File.Copy(From, To, true);
                                clearInputs();
                            }
                            else
                            {
                                MessageBox.Show("No se pudo registrar el Cliente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("El Cliente ya ha sido registrado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Beispiel #17
0
 // when Buscar Inquilino is clicked.
 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     string ID, Cedula;
     if (string.IsNullOrEmpty(txtIDInqui.Text))
     {
         ID = "";
     }
     else
     {
         ID = txtIDInqui.Text;
     }
     if (txtCedulaIn.MaskCompleted)
     {
         Cedula = txtCedulaIn.Text;
     }
     else
     {
         Cedula = "";
     }
     if (clientes.getCustomerObject(txtIDInqui.Text, txtCedulaIn.Text) != null)
     {
         // assign the ID value to the variable.
         iID = txtIDInqui.Text;
         // load the customer.
         clientes pClientes = clientes.getCustomerObject(ID, Cedula);
         if (pClientes.Status == "Inquilino")
         {
             pInquilino = pClientes;
             txtNameInqui.Text = pClientes.Nombre;
             pbInquilino.Image = Image.FromFile(pClientes.Image);
             txtLastNameInqui.Text = pClientes.Apellido;
             txtPhoneInqui.Text = pClientes.Telefono;
             txtCellphoneInqui.Text = pClientes.Celular;
             if(Convert.ToInt32(clientes.verifyDocument(ID, Cedula)) <= 0)
             {
                 rbCedulaIn.Checked = true;
             }
             else
             {
                 rbPasaporteIn.Checked = true;
             }
             txtCedulaIn.Text = pClientes.Cedula;
         }
         else
         {
             MessageBox.Show("El cliente seleccionado no ha sido clasificado correctamente, seleccione un Inquilino", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             btnSearchInqui.Focus();
         }
     }
     else
     {
         MessageBox.Show("EL Inquilino no existe, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Beispiel #18
0
 private void btnSearchInqui_Click(object sender, EventArgs e)
 {
     frmCustomerSearch pSearch = new frmCustomerSearch();
     pSearch.type = true;
     pSearch.Text = "Busqueda de Inquilino";
     pSearch.pGetStatus = "Inquilino";
     pSearch.ShowDialog();
     if(pSearch.pCustSelectedID != null)
     {
         // assign the ID value to the variable.
         iID = pSearch.pCustSelectedID;
         // load the customer.
         clientes pClientes = clientes.getCustomerObject(pSearch.pCustSelectedID, "");
         if (pClientes.Status == "Inquilino")
         {
             pInquilino = pClientes;
             txtIDInqui.Text = pClientes.ID;
             pbInquilino.Image = Image.FromFile(pClientes.Image);
             txtNameInqui.Text = pClientes.Nombre;
             txtLastNameInqui.Text = pClientes.Apellido;
             txtPhoneInqui.Text = pClientes.Telefono;
             txtCellphoneInqui.Text = pClientes.Celular;
             if(Convert.ToInt32(clientes.verifyDocument(pSearch.pCustSelectedID, "")) <= 0)
             {
                 rbCedulaIn.Checked = true;
             }
             else
             {
                 rbPasaporteIn.Checked = true;
             }
             txtCedulaIn.Text = pClientes.Cedula;
         }
         else
         {
             MessageBox.Show("El cliente no esta clasificado exitosamente, seleccione un Inquilino de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             btnSearchInqui.Focus();
         }
     }
     else
     {
         MessageBox.Show("No se selecciono un inquilino", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Beispiel #19
0
 // when buscar button is clicked.
 private void btnSearchSeller_Click(object sender, EventArgs e)
 {
     frmCustomerSearch pCustomer = new frmCustomerSearch();
     pCustomer.type = true;
     pCustomer.Text = "Buscar Vendedor";
     pCustomer.pGetStatus = "Vendedor";
     pCustomer.ShowDialog();
     if(pCustomer.pCustSelectedID != null)
     {
         try
         {
             if (clientes.getCustomerObject(pCustomer.pCustSelectedID, "") != null)
             {
                 clientes pClientes = clientes.getCustomerObject(pCustomer.pCustSelectedID, "");
                 if (pClientes.Status == "Vendedor")
                 {
                     pVendedor = pClientes;
                     vID = pClientes.ID;
                     txtIDSeller.Text = pClientes.ID;
                     pbVendedor.Image = Image.FromFile(pClientes.Image);
                     txtNameSeller.Text = pClientes.Nombre;
                     txtLastNameSeller.Text = pClientes.Apellido;
                     if(Convert.ToInt32(clientes.verifyDocument(pCustomer.pCustSelectedID, "")) <= 0)
                     {
                         rbCedulaVe.Checked = true;
                     }
                     else
                     {
                         rbPasaporteVe.Checked = true;
                     }
                     txtCedulaSeller.Text = pClientes.Cedula;
                     txtCelularSeller.Text = pClientes.Celular;
                     txtPhoneSeller.Text = pClientes.Telefono;
                 }
                 else
                 {
                     MessageBox.Show("No se selecciono un Vendedor, Seleccione uno valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     btnSearchSeller.Focus();
                 }
             }
             else
             {
                 MessageBox.Show("No existe el vendedor, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 txtIDSeller.Clear();
                 txtIDSeller.Focus();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("No se selecciono un Vendedor", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Beispiel #20
0
        // search engine for listing customers.
        public static List<clientes> searchCustomers(string ID, string name, string lastName, string cedula, string status, string registerDate)
        {
            List<clientes> list = new List<clientes>();
            using(SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand(string.Format("SELECT * FROM customers INNER JOIN Cities ON customers.CityID = Cities.ID INNER JOIN CustomerStatus ON CustomerStatus.ID = customers.StatusId WHERE customers.ID LIKE '{0}%' AND name LIKE '{1}%' AND lastname LIKE '{2}%' AND idcard LIKE '{3}%' AND status LIKE '{4}%' AND registerdate LIKE '{5}%' ",
                    ID, name, lastName, cedula, status, registerDate), con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    clientes pClientes = new clientes();
                    pClientes.ID = re["ID"].ToString();
                    pClientes.Nombre = re["name"].ToString();
                    pClientes.Apellido = re["lastname"].ToString();
                    pClientes.Cedula = re["idcard"].ToString();
                    pClientes.Image = re.GetString(5);
                    pClientes.Status = re["Status"].ToString();
                    pClientes.Fecha_Registro = re["registerdate"].ToString();
                    pClientes.Fecha_Registro = re["registerdate"].ToString();
                    pClientes.Direccion = re["cAddress"].ToString();
                    pClientes.E_Mail = re["email"].ToString();
                    pClientes.Ocupacion = re["ocupation"].ToString();
                    pClientes.Sector = re["City"].ToString();
                    pClientes.Telefono = re["Phone"].ToString();
                    pClientes.Celular = re["Cellphone"].ToString();

                    list.Add(pClientes);
                }
                con.Close();
            }
            return list;
        }
Beispiel #21
0
        // when buscar label is clicked.
        private void lblSearchBuy_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string ID, cedula;

            if (txtIDBuy.Text == string.Empty)
            {
                ID = "";
            }
            else
            {
                ID = txtIDBuy.Text;
            }
            if (txtCedulaBuy.MaskCompleted)
            {
                cedula = txtCedulaBuy.Text;
            }
            else
            {
                cedula = "";
            }
            try
            {
                if (clientes.getCustomerObject(ID, cedula) != null)
                {
                    clientes pClientes = clientes.getCustomerObject(ID, cedula);
                    if (pClientes.Status == "Comprador")
                    {
                        cID                 = pClientes.ID;
                        pComprador1         = pClientes;
                        pbComprador.Image   = Image.FromFile(pClientes.Image);
                        txtNameBuy.Text     = pClientes.Nombre;
                        txtLastNameBuy.Text = pClientes.Apellido;
                        if (Convert.ToInt32(clientes.verifyDocument(ID, cedula)) <= 0)
                        {
                            rbCedulaCo.Checked = true;
                        }
                        else
                        {
                            rbPasaporteCo.Checked = true;
                        }
                        txtCedulaBuy.Text  = pClientes.Cedula;
                        txtCelularBuy.Text = pClientes.Celular;
                        txtPhoneBuy.Text   = pClientes.Telefono;
                    }
                    else
                    {
                        MessageBox.Show("No se ha seleccionado un Comprador", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        btnSearchBuy.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("No existe el comprador, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtIDBuy.Clear();
                    txtIDBuy.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #22
0
 // method for getting customers data.
 public static clientes getCustomerObject(string ID, string idCard)
 {
     clientes pClientes = new clientes();
     using(SqlConnection con  = DBcomun.getConnection())
     {
         SqlCommand comand = new SqlCommand(string.Format("SELECT * FROM customers INNER JOIN Cities ON customers.CityID = Cities.ID INNER JOIN CustomerStatus ON CustomerStatus.ID = customers.StatusId WHERE customers.ID = '{0}' OR customers.idcard = '{1}'", ID, idCard), con);
         SqlDataReader re = comand.ExecuteReader();
         if (re.HasRows)
         {
             while (re.Read())
             {
                 pClientes.ID = re["ID"].ToString();
                 pClientes.Nombre = re["name"].ToString();
                 pClientes.Apellido = re["lastname"].ToString();
                 pClientes.Cedula = re["idcard"].ToString();
                 pClientes.Image = re.GetString(5);
                 pClientes.Status = re["Status"].ToString();
                 pClientes.Fecha_Registro = re["registerdate"].ToString();
                 pClientes.Fecha_Registro = re["registerdate"].ToString();
                 pClientes.Direccion = re["cAddress"].ToString();
                 pClientes.E_Mail = re["email"].ToString();
                 pClientes.Ocupacion = re["ocupation"].ToString();
                 pClientes.Sector = re["City"].ToString();
                 pClientes.Telefono = re["Phone"].ToString();
                 pClientes.Celular = re["Cellphone"].ToString();
             }
         }
         else
         {
             pClientes = null;
         }
         con.Close();
     }
     return pClientes;
 }
Beispiel #23
0
 // when label buscar is clicked on Demandado.
 private void lblSearchDemandante_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     string ID, cedula;
     // verify if the id is empty.
     if (txtIDDemandante.Text == string.Empty)
     {
         ID = "";
     }
     else
     {
         ID = txtIDDemandante.Text;
     }
     if (txtCedulaDemandante.MaskCompleted)
     {
         cedula = txtCedulaDemandante.Text;
     }
     else
     {
         cedula = "";
     }
     try
     {
         if (clientes.getCustomerObject(ID, cedula) != null)
         {
             clientes pClientes = clientes.getCustomerObject(ID, cedula);
             if (pClientes.Status == "Demandante")
             {
                 cID1 = pClientes.ID;
                 pDemandante = pClientes;
                 pbDemandante.Image = Image.FromFile(pClientes.Image);
                 txtNameDemandante.Text = pClientes.Nombre;
                 txtLastNameDemandante.Text = pClientes.Apellido;
                 txtPhoneDemandante.Text = pClientes.Telefono;
                 txtCellphoneDemandante.Text = pClientes.Celular;
                 if(Convert.ToInt32(clientes.verifyDocument(ID, cedula)) <= 0)
                 {
                     rbCedulaE.Checked = true;
                 }
                 else
                 {
                     rbPasaporteE.Checked = true;
                 }
                 txtCedulaDemandante.Text = pClientes.Cedula;
             }
             else
             {
                 MessageBox.Show("El cliente no se ha seleccionado como un demandante, seleccione uno valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 btnSearchDemandante.Focus();
             }
         }
         else
         {
             MessageBox.Show("El cliente no existe, digite un id valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txtIDDemandante.Clear();
             txtIDDemandante.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #24
0
 // when buscar label is clicked.
 private void lblSearchSeller_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     string ID, cedula;
     if (txtIDSeller.Text == string.Empty)
     {
         ID = "";
     }
     else
     {
         ID = txtIDSeller.Text;
     }
     if (txtCedulaSeller.MaskCompleted)
     {
         cedula = txtCedulaSeller.Text;
     }
     else
     {
         cedula = "";
     }
     try
     {
         if (clientes.getCustomerObject(ID, cedula) != null)
         {
             clientes pClientes = clientes.getCustomerObject(ID, cedula);
             if (pClientes.Status == "Vendedor")
             {
                 vID = pClientes.ID;
                 pVendedor = pClientes;
                 pbVendedor.Image = Image.FromFile(pClientes.Image);
                 txtNameSeller.Text = pClientes.Nombre;
                 txtLastNameSeller.Text = pClientes.Apellido;
                 if(Convert.ToInt32(clientes.verifyDocument(ID, cedula)) <= 0)
                 {
                     rbCedulaVe.Checked = true;
                 }
                 else
                 {
                     rbPasaporteVe.Checked = true;
                 }
                 txtCedulaSeller.Text = pClientes.Cedula;
                 txtCelularSeller.Text = pClientes.Celular;
                 txtPhoneSeller.Text = pClientes.Telefono;
             }
             else
             {
                 MessageBox.Show("No se selecciono un vendedor", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 btnSearchSeller.Focus();
             }
         }
         else
         {
             MessageBox.Show("No existe el vendedor, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txtIDSeller.Clear();
             txtIDSeller.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #25
0
 // when buscar demandante button is clicked.
 private void btnSearchDemandante_Click(object sender, EventArgs e)
 {
     frmCustomerSearch pCustomer = new frmCustomerSearch();
     pCustomer.type = true;
     pCustomer.Text = "Busqueda Demandante";
     pCustomer.pGetStatus = "Demandante";
     pCustomer.ShowDialog();
     if(pCustomer.pCustSelectedID != null)
     {
         try
         {
             if (clientes.getCustomerObject(pCustomer.pCustSelectedID, "") != null)
             {
                 clientes pClientes = clientes.getCustomerObject(pCustomer.pCustSelectedID, "");
                 if (pClientes.Status == "Demandante")
                 {
                     pDemandante = pClientes;
                     cID1 = pClientes.ID;
                     pbDemandante.Image = Image.FromFile(pClientes.Image);
                     txtIDDemandante.Text = pClientes.ID;
                     txtNameDemandante.Text = pClientes.Nombre;
                     txtLastNameDemandante.Text = pClientes.Apellido;
                     txtPhoneDemandante.Text = pClientes.Telefono;
                     txtCellphoneDemandante.Text = pClientes.Celular;
                     if(Convert.ToInt32(clientes.verifyDocument(pCustomer.pCustSelectedID, "")) <= 0)
                     {
                         rbCedulaE.Checked = true;
                     }
                     else
                     {
                         rbPasaporteE.Checked = true;
                     }
                     txtCedulaDemandante.Text = pClientes.Cedula;
                 }
                 else
                 {
                     MessageBox.Show("El cliente no ha sido registrado como un demandante, seleccione uno diferente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     btnSearchDemandante.Focus();
                 }
             }
             else
             {
                 MessageBox.Show("El cliente no existe, digite un id valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 txtIDDemandante.Clear();
                 txtIDDemandante.Focus();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("No se selecciono el Demandante, Intentelo nuevamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }