Beispiel #1
0
 // when form is loaded.
 private void frmShowService_Load(object sender, EventArgs e)
 {
     // validate ID value.
     if (ID != null)
     {
         // execute  the method for getting service info.
         if (servicios.getServiceInfo(ID) != null)
         {
             // if was found something with the id.
             servicios pServices = servicios.getServiceInfo(ID);
             lblService.Text       = pServices.Servicio;
             txtDescription.Text   = pServices.Descripcion;
             lblPrice.Text         = pServices.Precio;
             lblPre_bono.Text      = pServices.Abono;
             lblPre_bono.ForeColor = Color.Yellow;
             // disable the texbox.
             txtDescription.Enabled = false;
         }
         else
         {
             MessageBox.Show("Servicio no encontrado, digite un ID valido", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         // If ID is found NULL. do something...
     }
 }
 // when Guardar button is clicked.
 private void btnSave_Click(object sender, EventArgs e)
 {
     // validate empty inputs.
     if(txtServices.Text == string.Empty)
     {
         MessageBox.Show("Nombre del Servicio vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtServices.Focus();
     }
     else if(txtDescription.Text == string.Empty)
     {
         MessageBox.Show("Descripcion vacia", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtDescription.Focus();
     }
     else if(txtPrice.Text == string.Empty)
     {
         MessageBox.Show("Precio del servicio vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtPrice.Focus();
     }
     else if(txtPreBonus.Text == string.Empty)
     {
         MessageBox.Show("Abono vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtPreBonus.Focus();
     }
     else
     {
         // if all inputs are filled.
         // create an instance of servicios class.
         servicios pServicios = new servicios();
         pServicios.Servicio = txtServices.Text;
         pServicios.Descripcion = txtDescription.Text;
         pServicios.Precio = txtPrice.Text;
         pServicios.Abono = txtPreBonus.Text;
         // end of object ///
         // make a try catch.
         try {
             // now let's execute the registration method.
             if (servicios.registerService(pServicios) > 0)
             {
                 MessageBox.Show("Registrado con Exito", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 // clear all inputs if registration is successfull.
                 clearInputs();
             }
             else
             {
                 MessageBox.Show("No se pudo registrar, Intentelo nuevamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch(Exception ex)
         {
             MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #3
0
 // end custructors building.
 // method for to register services to the database.
 public static int registerService(servicios pServicio)
 {
     int re = -1;
     using(SqlConnection con = DBcomun.getConnection())
     {
         SqlCommand comand = new SqlCommand(string.Format("INSERT INTO services (cService, explanation, price, pre_bono) VALUES ('{0}', '{1}', '{2}', '{3}')",
             pServicio.Servicio, pServicio.Descripcion, pServicio.Precio, pServicio.Abono), con);
         re = comand.ExecuteNonQuery();
         con.Close();
     }
     return re;
 }
 // when Guardar button is clicked.
 private void btnSave_Click(object sender, EventArgs e)
 {
     // validate empty inputs.
     if (txtServices.Text == string.Empty)
     {
         MessageBox.Show("Nombre del Servicio vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtServices.Focus();
     }
     else if (txtDescription.Text == string.Empty)
     {
         MessageBox.Show("Descripcion vacia", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtDescription.Focus();
     }
     else if (txtPrice.Text == string.Empty)
     {
         MessageBox.Show("Precio del servicio vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtPrice.Focus();
     }
     else if (txtPreBonus.Text == string.Empty)
     {
         MessageBox.Show("Abono vacio", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtPreBonus.Focus();
     }
     else
     {
         // if all inputs are filled.
         // create an instance of servicios class.
         servicios pServicios = new servicios();
         pServicios.Servicio    = txtServices.Text;
         pServicios.Descripcion = txtDescription.Text;
         pServicios.Precio      = txtPrice.Text;
         pServicios.Abono       = txtPreBonus.Text;
         // end of object ///
         // make a try catch.
         try {
             // now let's execute the registration method.
             if (servicios.registerService(pServicios) > 0)
             {
                 MessageBox.Show("Registrado con Exito", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 // clear all inputs if registration is successfull.
                 clearInputs();
             }
             else
             {
                 MessageBox.Show("No se pudo registrar, Intentelo nuevamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #5
0
        // end custructors building.
        // method for to register services to the database.
        public static int registerService(servicios pServicio)
        {
            int re = -1;

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand(string.Format("INSERT INTO services (cService, explanation, price, pre_bono) VALUES ('{0}', '{1}', '{2}', '{3}')",
                                                                 pServicio.Servicio, pServicio.Descripcion, pServicio.Precio, pServicio.Abono), con);
                re = comand.ExecuteNonQuery();
                con.Close();
            }
            return(re);
        }
Beispiel #6
0
        // method for getting service info from database.
        public static servicios getServiceInfo(string ID)
        {
            servicios pServicios = new servicios();

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand    comand = new SqlCommand(string.Format("SELECT * FROM services WHERE ID = {0}", ID), con);
                SqlDataReader re     = comand.ExecuteReader();
                while (re.Read())
                {
                    pServicios.ID          = re["ID"].ToString();
                    pServicios.Servicio    = re["cService"].ToString();
                    pServicios.Descripcion = re["explanation"].ToString();
                    pServicios.Precio      = re["price"].ToString();
                    pServicios.Abono       = re["pre_bono"].ToString();
                }
                con.Close();
            }
            return(pServicios);
        }
Beispiel #7
0
        // method for listing all services.
        public static List<servicios> listAllServices()
        {
            List<servicios> list = new List<servicios>();
            using(SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand("SELECT * FROM services", con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    servicios pServicios = new servicios();
                    pServicios.ID = re["ID"].ToString();
                    pServicios.Servicio = re["cService"].ToString();
                    pServicios.Descripcion = re["explanation"].ToString();
                    pServicios.Precio = re["price"].ToString();
                    pServicios.Abono = re["pre_bono"].ToString();

                    list.Add(pServicios);
                }
                con.Close();
            }
            return list;
        }
Beispiel #8
0
        // search engine for services
        public static List<servicios> searchServices(string id, string service, string description, string price, string pre_bono)
        {
            List<servicios> list = new List<servicios>();
            using(SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand(string.Format("select * from services where ID like '{0}%' and cService like '{1}%' and explanation like '{2}%' and price like '{3}%' and pre_bono like '{4}%'",
                    id, service, description, price, pre_bono), con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    servicios pServicios = new servicios();
                    pServicios.ID = re["ID"].ToString();
                    pServicios.Servicio = re["cService"].ToString();
                    pServicios.Descripcion = re["explanation"].ToString();
                    pServicios.Precio = re["price"].ToString();
                    pServicios.Abono = re["pre_bono"].ToString();

                    list.Add(pServicios);
                }
                con.Close();
            }
            return list;
        }
Beispiel #9
0
        // method for listing all services.
        public static List <servicios> listAllServices()
        {
            List <servicios> list = new List <servicios>();

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand    comand = new SqlCommand("SELECT * FROM services", con);
                SqlDataReader re     = comand.ExecuteReader();
                while (re.Read())
                {
                    servicios pServicios = new servicios();
                    pServicios.ID          = re["ID"].ToString();
                    pServicios.Servicio    = re["cService"].ToString();
                    pServicios.Descripcion = re["explanation"].ToString();
                    pServicios.Precio      = re["price"].ToString();
                    pServicios.Abono       = re["pre_bono"].ToString();

                    list.Add(pServicios);
                }
                con.Close();
            }
            return(list);
        }
Beispiel #10
0
        // search engine for services
        public static List <servicios> searchServices(string id, string service, string description, string price, string pre_bono)
        {
            List <servicios> list = new List <servicios>();

            using (SqlConnection con = DBcomun.getConnection())
            {
                SqlCommand comand = new SqlCommand(string.Format("select * from services where ID like '{0}%' and cService like '{1}%' and explanation like '{2}%' and price like '{3}%' and pre_bono like '{4}%'",
                                                                 id, service, description, price, pre_bono), con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    servicios pServicios = new servicios();
                    pServicios.ID          = re["ID"].ToString();
                    pServicios.Servicio    = re["cService"].ToString();
                    pServicios.Descripcion = re["explanation"].ToString();
                    pServicios.Precio      = re["price"].ToString();
                    pServicios.Abono       = re["pre_bono"].ToString();

                    list.Add(pServicios);
                }
                con.Close();
            }
            return(list);
        }
Beispiel #11
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 #12
0
 // method for getting service info from database.
 public static servicios getServiceInfo(string ID)
 {
     servicios pServicios = new servicios();
     using(SqlConnection con = DBcomun.getConnection())
     {
         SqlCommand comand = new SqlCommand(string.Format("SELECT * FROM services WHERE ID = {0}", ID), con);
         SqlDataReader re = comand.ExecuteReader();
         while (re.Read())
         {
             pServicios.ID = re["ID"].ToString();
             pServicios.Servicio = re["cService"].ToString();
             pServicios.Descripcion = re["explanation"].ToString();
             pServicios.Precio = re["price"].ToString();
             pServicios.Abono = re["pre_bono"].ToString();
         }
         con.Close();
     }
     return pServicios;
 }