private void msk_Identi_Leave(object sender, EventArgs e)
 {
     if (msk_Identi.Text.Trim() == "- -" && estaCargando == false)
     {
         erpErrores.SetError(msk_Identi, "este campo es obligatorio");
         msk_Identi.Focus();
     }
     else if (estaCargando == false)
     {
         cls_Clientes_BLL Obj_Bll = new cls_Clientes_BLL();
         cls_Clientes_DAL Obj_DAL = new cls_Clientes_DAL();
         Obj_Cliente_DAL.Siden = msk_Identi.Text.Trim();
         if (Obj_Bll.clienteRepetido(ref Obj_Cliente_DAL))
         {
             MessageBox.Show(Obj_Cliente_DAL.sMgsError, "Cedula repetida", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             msk_Identi.ResetText();
             msk_Identi.Focus();
         }
         else
         {
             txt_nombre.Enabled    = true;
             txt_prim_ape.Enabled  = true;
             txt_seg_ape.Enabled   = true;
             txt_Telefono1.Enabled = true;
             txt_Telefono2.Enabled = true;
             txt_correo.Enabled    = true;
             txt_direccion.Enabled = true;
             txt_nombre.Focus();
         }
     }
     else
     {
         estaCargando = false;
     }
 }
Exemple #2
0
        private void btn_Eliminar_Click(object sender, EventArgs e)
        {
            cls_Clientes_BLL objBLL    = new cls_Clientes_BLL();
            string           sMsjError = string.Empty;

            if (dgv_Clientes.Rows.Count > 0)
            {
                if (MessageBox.Show("Realmente desea eliminar?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    objBLL.Eliminar_Clientes(ref sMsjError, dgv_Clientes.SelectedRows[0].Cells[0].Value.ToString());

                    if (sMsjError != string.Empty)
                    {
                        MessageBox.Show("Se presento un error a la hora de listar : [ " + sMsjError + " ]", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Registro eliminado correctamente", "Listo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        CargarDatos();
                    }
                    txtFiltro.Text = string.Empty;
                }
            }
            else
            {
                MessageBox.Show("No hay registros para eliminar");
            }
        }
Exemple #3
0
        private void CargarDatos()
        {
            cls_Clientes_BLL Obj_Clientes_BLL = new cls_Clientes_BLL();
            string           sMsjError        = string.Empty;
            DataTable        dtClientes       = new DataTable();

            if (txtFiltro.Text == string.Empty)
            {
                dtClientes = Obj_Clientes_BLL.Listar_Clientes(ref sMsjError);
            }
            else
            {
                dtClientes = Obj_Clientes_BLL.Filtrar_Clientes(ref sMsjError, txtFiltro.Text.Trim());
            }

            if (sMsjError == string.Empty)
            {
                dgv_Clientes.DataSource = null;
                dgv_Clientes.DataSource = dtClientes;
            }
            else
            {
                dgv_Clientes.DataSource = null;
                MessageBox.Show("Se presentó un error : [ " + sMsjError + " ]. ", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txt_ID_Cliente.Text) || (string.IsNullOrEmpty(txt_Cedula.Text)) || (string.IsNullOrEmpty(txt_Nombre.Text)) || (string.IsNullOrEmpty(txt_Apellidos.Text)) || (string.IsNullOrEmpty(txt_Telefono.Text)) || (cmb_ID_Estado.SelectedValue.ToString() == "0") || (cmb_ID_Tipo_Cliente.SelectedValue.ToString() == "0") || (txt_Cedula.Text.Length < 11) || (txt_Telefono.Text.Length < 9))
            {
                MessageBox.Show("No se puede guardar sin no están todos los datos", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string           sMsjError       = string.Empty;
                cls_Clientes_BLL ObjClientes_BLL = new cls_Clientes_BLL();
                ObjClientes_DAL.sIdCliente     = txt_ID_Cliente.Text;
                ObjClientes_DAL.sCedula        = txt_Cedula.Text;
                ObjClientes_DAL.sNombre        = txt_Nombre.Text;
                ObjClientes_DAL.sApellido      = txt_Apellidos.Text;
                ObjClientes_DAL.sTelefono      = txt_Telefono.Text;
                ObjClientes_DAL.sIdTipoCliente = cmb_ID_Tipo_Cliente.SelectedValue.ToString();
                ObjClientes_DAL.cIdEstado      = Convert.ToChar(cmb_ID_Estado.SelectedValue.ToString());

                if (ObjClientes_DAL.cBandAxn == 'I')
                {
                    ObjClientes_BLL.Insertar_Clientes(ref sMsjError, ref ObjClientes_DAL);
                    if (sMsjError == string.Empty)
                    {
                        MessageBox.Show("Se han ingresado los datos correctamente", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lb_Guardar.Text = "Modificar";
                    }
                    else
                    {
                        MessageBox.Show("Hubo un Error y los Datos no han sido agregados:" + " [ " + sMsjError + " ] ", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if ((ObjClientes_DAL.cBandAxn == 'U') || (ObjClientes_DAL != null))
                {
                    ObjClientes_BLL.Modificar_Clientes(ref sMsjError, ref ObjClientes_DAL);

                    if (sMsjError == string.Empty)
                    {
                        MessageBox.Show("Se han ingresado los datos correctamente", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Hubo un Error y los Datos no han sido agregados:" + " [ " + sMsjError + " ] ", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            cls_Clientes_BLL Obj_Cliente_BLL = new cls_Clientes_BLL();

            Obj_Cliente_DAL.sNombres    = txt_nombre.Text.Trim();
            Obj_Cliente_DAL.sApellidos  = txt_prim_ape.Text.Trim() + " " + txt_seg_ape.Text.Trim();
            Obj_Cliente_DAL.Siden       = msk_Identi.Text;
            Obj_Cliente_DAL.iNumeroTele = Convert.ToInt32(txt_Telefono1.Text.Trim());
            Obj_Cliente_DAL.iNumeroCel  = Convert.ToInt32(txt_Telefono2.Text.Trim());
            Obj_Cliente_DAL.sCorreo     = txt_correo.Text.Trim();
            Obj_Cliente_DAL.sDireccion  = txt_direccion.Text.Trim();
            Obj_Cliente_DAL.FechaCreado = DateTime.Now;
            Obj_Cliente_BLL.Insert_Clientes(ref Obj_Cliente_DAL);
            if (Obj_Cliente_DAL.iCod_Id != -1)
            {
                cls_VehiPorClientes_BLL Obj_Vh_BLL = new cls_VehiPorClientes_BLL();
                cls_VehiPorClientes_DAL Obj_Vh_DAL = new cls_VehiPorClientes_DAL();
                Obj_Vh_DAL.iId_Cliente           = Obj_Cliente_DAL.iCod_Id;
                Obj_Vh_DAL.sPlaca                = msk_placa.Text.Trim();
                Obj_Vh_DAL.iCod_TipoVehiculos    = Convert.ToInt32(cbx_tipos.SelectedValue);
                Obj_Vh_DAL.iCod_Combustible      = Convert.ToInt32(cbx_combus.SelectedValue);
                Obj_Vh_DAL.iCod_MarcasVehiculos  = Convert.ToInt32(cmb_Marca.SelectedValue);
                Obj_Vh_DAL.iCod_ModelosVehiculos = Convert.ToInt32(cmb_Modelo.SelectedValue);
                Obj_Vh_DAL.iAnio       = Convert.ToInt32(nUD_Anio.Value);
                Obj_Vh_DAL.sComentario = txt_comentario.Text.Trim();
                Obj_Vh_BLL.Insert_VehiPorClientes(ref Obj_Vh_DAL);
                if (Obj_Vh_DAL.sMgsError == "")
                {
                    MessageBox.Show("Cliente registrado \nexitosamente!!", "Resultado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(Obj_Vh_DAL.sMgsError, "Ocurrio un error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }