Exemplo n.º 1
0
        private void frmGeneracionContrasena_Load(object sender, EventArgs e)
        {
            _dbCosolemEntities = new dbCosolemEntities();

            _tbPersona = null;

            cmbTipoIdentificacion.DataSource    = (from TI in _dbCosolemEntities.tbTipoIdentificacion where TI.idTipoIdentificacion != 2 select new TipoIdentificacion {
                idTipoIdentificacion = TI.idTipoIdentificacion, descripcion = TI.descripcion, cantidadCaracteres = TI.cantidadCaracteres
            }).ToList();
            cmbTipoIdentificacion.ValueMember   = "idTipoIdentificacion";
            cmbTipoIdentificacion.DisplayMember = "descripcion";
            cmbTipoIdentificacion_SelectionChangeCommitted(null, null);

            cmbTipoIdentificacion.Enabled = true;
            txtNumeroIdentificacion.Clear();
            txtNumeroIdentificacion.Enabled = true;

            txtNombresCompletos.Clear();
            txtCorreoElectronico.Enabled = true;
            txtCorreoElectronico.Clear();
            txtNombreUsuario.Enabled = true;
            txtNombreUsuario.Clear();
            txtContrasena.Clear();
            chbContrasenaNuncaExpira.Checked = false;
            chbCambiarContrasena.Checked     = true;

            txtNumeroIdentificacion.Select();
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            tbPersona tbPersona = db.tbPersona.Find(id);

            db.tbPersona.Remove(tbPersona);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "codPersona,primerNombre,segundoNombre,primerApellido,segundoApellido,telefono,fechaNacimiento")] tbPersona tbPersona)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbPersona).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbPersona));
 }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "codPersona,primerNombre,segundoNombre,primerApellido,segundoApellido,telefono,fechaNacimiento")] tbPersona tbPersona)
        {
            if (ModelState.IsValid)
            {
                db.tbPersona.Add(tbPersona);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbPersona));
        }
Exemplo n.º 5
0
        private void SetearPersona(tbPersona _tbPersona)
        {
            cmbTipoPersona.SelectedValue = _tbPersona.idTipoPersona;
            cmbTipoPersona_SelectionChangeCommitted(null, null);
            cmbTipoIdentificacion.SelectedValue = _tbPersona.idTipoIdentificacion;
            cmbTipoIdentificacion_SelectionChangeCommitted(null, null);
            txtNumeroIdentificacion.Text = _tbPersona.numeroIdentificacion;
            txtNumeroIdentificacion.Tag  = _tbPersona.idPersona;
            txtPrimerNombre.Text         = _tbPersona.primerNombre;
            txtSegundoNombre.Text        = _tbPersona.segundoNombre;
            txtApellidoPaterno.Text      = _tbPersona.apellidoPaterno;
            txtApellidoMaterno.Text      = _tbPersona.apellidoMaterno;
            txtRazonSocial.Text          = _tbPersona.razonSocial;
            txtCorreoElectronico.Text    = _tbPersona.correoElectronico;
            tbDireccion _tbDireccion = _tbPersona.tbDireccion.Where(x => x.esPrincipal).FirstOrDefault();

            if (_tbDireccion != null)
            {
                cmbProvinciaCliente.SelectedValue = _tbDireccion.tbCanton.idProvincia;
                cmbProvinciaCliente_SelectionChangeCommitted(null, null);
                cmbCantonCliente.SelectedValue = _tbDireccion.idCanton;
                tbTelefono _tbTelefonoConvencional = _tbDireccion.tbTelefono.Where(x => x.idTipoTelefono == 1).FirstOrDefault();
                if (_tbTelefonoConvencional != null)
                {
                    txtConvencional.Tag  = _tbTelefonoConvencional.idTelefono;
                    txtConvencional.Text = _tbTelefonoConvencional.numero;
                }
                tbTelefono _tbTelefonoCelular = _tbDireccion.tbTelefono.Where(x => x.idTipoTelefono == 2).FirstOrDefault();
                if (_tbTelefonoCelular != null)
                {
                    txtCelular.Tag  = _tbTelefonoCelular.idTelefono;
                    txtCelular.Text = _tbTelefonoCelular.numero;
                }
                txtDireccionCliente.Tag  = _tbDireccion.idDireccion;
                txtDireccionCliente.Text = _tbDireccion.direccionCompleta;
            }
            cmbTipoPersona.Enabled          = false;
            cmbTipoIdentificacion.Enabled   = false;
            txtNumeroIdentificacion.Enabled = false;
            if (_tbPersona.idTipoPersona == 1)
            {
                txtPrimerNombre.Select();
            }
            if (_tbPersona.idTipoPersona == 2)
            {
                txtRazonSocial.Select();
            }

            string   numeroIdentificacion = txtNumeroIdentificacion.Text.Trim();
            DateTime?fechaAgendamiento    = (dtpFechaHoraAgendamiento.Checked ? dtpFechaHoraAgendamiento.Value : (DateTime?)null);
            long?    idTecnico            = ((Tecnico)cmbTecnicoAsignado.SelectedItem).idEmpleado;

            ConsultarAgendamientos(numeroIdentificacion, fechaAgendamiento, idTecnico);
        }
Exemplo n.º 6
0
        private void txtNumeroIdentificacion_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                int    idTipoPersona        = ((TipoPersona)cmbTipoPersona.SelectedItem).idTipoPersona;
                int    idTipoIdentificacion = ((TipoIdentificacion)cmbTipoIdentificacion.SelectedItem).idTipoIdentificacion;
                string numeroIdentificacion = txtNumeroIdentificacion.Text.Trim();

                tbPersona _tbPersona = (from P in _dbCosolemEntities.tbPersona where P.idTipoPersona == idTipoPersona && P.idTipoIdentificacion == idTipoIdentificacion && P.numeroIdentificacion == numeroIdentificacion select P).FirstOrDefault();
                if (_tbPersona == null)
                {
                    MessageBox.Show("Cliente no exite, favor registre sus datos", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    SetearPersona(_tbPersona);
                }

                if (idTipoPersona == 1)
                {
                    txtPrimerNombre.Select();
                }
                if (idTipoPersona == 2)
                {
                    txtRazonSocial.Select();
                }
            }
            else
            {
                int idTipoIdentificacion = ((TipoIdentificacion)cmbTipoIdentificacion.SelectedItem).idTipoIdentificacion;
                if (new List <int> {
                    1, 2
                }.Contains(idTipoIdentificacion))
                {
                    if (!(char.IsNumber(e.KeyChar)) && (e.KeyChar != (char)Keys.Back))
                    {
                        e.Handled = true;
                        return;
                    }
                }
                else
                {
                    if (!(char.IsLetter(e.KeyChar)) && !(char.IsNumber(e.KeyChar)) && (e.KeyChar != (char)Keys.Back))
                    {
                        e.Handled = true;
                        return;
                    }
                }
            }
        }
Exemplo n.º 7
0
        // GET: Persona/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbPersona tbPersona = db.tbPersona.Find(id);

            if (tbPersona == null)
            {
                return(HttpNotFound());
            }
            return(View(tbPersona));
        }
Exemplo n.º 8
0
 private void SetearPersona(tbPersona _tbPersona)
 {
     try
     {
         this._tbPersona = _tbPersona;
         if (this._tbPersona.tbEmpleado.tbUsuario == null)
         {
             _tbPersona.tbEmpleado.tbUsuario = new tbUsuario {
                 estadoRegistro = true
             }
         }
         ;
         else
         {
             txtCorreoElectronico.Enabled = false;
             txtNombreUsuario.Enabled     = false;
         }
         cmbTipoIdentificacion.SelectedValue = this._tbPersona.idTipoIdentificacion;
         cmbTipoIdentificacion_SelectionChangeCommitted(null, null);
         txtNumeroIdentificacion.Text    = this._tbPersona.numeroIdentificacion;
         cmbTipoIdentificacion.Enabled   = false;
         txtNumeroIdentificacion.Enabled = false;
         txtNombresCompletos.Text        = this._tbPersona.nombreCompleto;
         string correoElectronico = this._tbPersona.tbEmpleado.correoElectronico;
         string nombreUsuario     = this._tbPersona.tbEmpleado.tbUsuario == null ? null : this._tbPersona.tbEmpleado.tbUsuario.nombreUsuario;
         if (String.IsNullOrEmpty(nombreUsuario))
         {
             nombreUsuario = this._tbPersona.primerNombre.Trim().Substring(0, 1) + this._tbPersona.apellidoPaterno;
             int cantidad = (from U in _dbCosolemEntities.tbUsuario where U.nombreUsuario == nombreUsuario select U).Count();
             if (cantidad > 0)
             {
                 nombreUsuario += (cantidad + 1).ToString();
             }
         }
         if (String.IsNullOrEmpty(correoElectronico))
         {
             correoElectronico = nombreUsuario + "@" + _tbPersona.tbEmpleado.tbEmpresa.dominio;
         }
         txtCorreoElectronico.Text        = correoElectronico;
         txtNombreUsuario.Text            = nombreUsuario;
         txtContrasena.Text               = Util.GeneraContrasena();
         chbContrasenaNuncaExpira.Checked = false;
         chbCambiarContrasena.Checked     = true;
     }
     catch (Exception ex)
     {
         Util.MostrarException(this.Text, ex);
     }
 }
Exemplo n.º 9
0
        private string VerificaPersona(int idTipoPersona, int idTipoIdentificacion, string numeroIdentificacion)
        {
            string mensaje = String.Empty;

            if (this._tbPersona.idPersona == 0)
            {
                tbPersona _tbPersona = (from P in _dbCosolemEntities.tbPersona where P.idTipoPersona == idTipoPersona && P.idTipoIdentificacion == idTipoIdentificacion && P.numeroIdentificacion == numeroIdentificacion select P).FirstOrDefault();
                if (_tbPersona != null)
                {
                    if (_tbPersona.tbCliente != null)
                    {
                        mensaje += "Persona se encuentra registrada, favor verificar\n";
                    }
                }
            }
            return(mensaje);
        }
Exemplo n.º 10
0
 public static bool SavePersona(tbPersona p)
 {
     try
     {
         using (bdCURPEntities _entity = new bdCURPEntities())
         {
             _entity.tbPersonas.Add(p);
             _entity.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
Exemplo n.º 11
0
 private void SetearPersona(tbPersona _tbPersona)
 {
     try
     {
         this._tbPersona = _tbPersona;
         if (this._tbPersona.tbCliente == null)
         {
             this._tbPersona.tbCliente = new tbCliente {
                 estadoRegistro = true
             };
             MessageBox.Show("Cliente no se encuentra registrado, favor completar los datos", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         cmbTipoPersona.SelectedValue = this._tbPersona.idTipoPersona;
         cmbTipoPersona_SelectionChangeCommitted(null, null);
         cmbTipoIdentificacion.SelectedValue = this._tbPersona.idTipoIdentificacion;
         txtNumeroIdentificacion.Text        = this._tbPersona.numeroIdentificacion;
         txtPrimerNombre.Text       = this._tbPersona.primerNombre;
         txtSegundoNombre.Text      = this._tbPersona.segundoNombre;
         txtApellidoPaterno.Text    = this._tbPersona.apellidoPaterno;
         txtApellidoMaterno.Text    = this._tbPersona.apellidoMaterno;
         txtRazonSocial.Text        = this._tbPersona.razonSocial;
         cmbSexo.SelectedValue      = this._tbPersona.idSexo;
         dtpFechaNacimiento.Checked = false;
         if (this._tbPersona.fechaNacimiento.HasValue)
         {
             dtpFechaNacimiento.Value = this._tbPersona.fechaNacimiento.Value;
         }
         cmbEstadoCivil.SelectedValue = this._tbPersona.idEstadoCivil;
         txtCorreoElectronico.Text    = this._tbPersona.correoElectronico;
         _BindingListtbDireccion.Clear();
         this._tbPersona.tbDireccion.Where(x => x.estadoRegistro).ToList().ForEach(x =>
         {
             x.descripcionProvincia     = x.tbCanton.tbProvincia.descripcion;
             x.descripcionCanton        = x.tbCanton.descripcion;
             x.descripcionTipoDireccion = x.tbTipoDireccion.descripcion;
             _BindingListtbDireccion.Add(x);
         });
         _BindingListtbTelefonoPersonal.Clear();
         this._tbPersona.tbTelefonoPersonal.Where(x => x.estadoRegistro).ToList().ForEach(x => _BindingListtbTelefonoPersonal.Add(x));
     }
     catch (Exception ex)
     {
         Util.MostrarException(this.Text, ex);
     }
 }
Exemplo n.º 12
0
 private void txtNumeroIdentificacion_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         string    numeroIdentificacion = txtNumeroIdentificacion.Text.Trim();
         tbPersona _tbPersona           = (from P in _dbCosolemEntities.tbPersona join E in _dbCosolemEntities.tbEmpleado on new { idEmpleado = P.idPersona, P.estadoRegistro } equals new { E.idEmpleado, E.estadoRegistro } where P.estadoRegistro && P.idTipoPersona == 1 && P.numeroIdentificacion == numeroIdentificacion select P).FirstOrDefault();
         if (_tbPersona != null)
         {
             SetearPersona(_tbPersona);
         }
         else
         {
             MessageBox.Show("Empleado no se encuentra registrado, favor verificar", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         int idTipoIdentificacion = ((TipoIdentificacion)cmbTipoIdentificacion.SelectedItem).idTipoIdentificacion;
         if (new List <int> {
             1, 2
         }.Contains(idTipoIdentificacion))
         {
             if (!(char.IsNumber(e.KeyChar)) && (e.KeyChar != (char)Keys.Back))
             {
                 e.Handled = true;
                 return;
             }
         }
         else
         {
             if (!(char.IsLetter(e.KeyChar)) && !(char.IsNumber(e.KeyChar)) && (e.KeyChar != (char)Keys.Back))
             {
                 e.Handled = true;
                 return;
             }
         }
     }
 }
Exemplo n.º 13
0
        private void frmCaja_Load(object sender, EventArgs e)
        {
            _dbCosolemEntities = new dbCosolemEntities();

            dgvOrdenVentaDetalle.AutoGenerateColumns   = false;
            dgvOrdenVentaFormaPago.AutoGenerateColumns = false;

            _BindingListtbOrdenVentaFormaPago = new BindingList <tbOrdenVentaFormaPago>();

            ordenVenta = (from OVC in _dbCosolemEntities.tbOrdenVentaCabecera where OVC.tipoOrdenVenta == "O" && OVC.idEstadoOrdenVenta == 1 && OVC.estadoRegistro && OVC.idOrdenVentaCabecera == idOrdenVenta select OVC).FirstOrDefault();
            tbPersona persona = ordenVenta.tbCliente.tbPersona;

            txtCliente.Text = ordenVenta.cliente;
            txtNumeroIdentificacion.Text = persona.numeroIdentificacion;
            txtDireccion.Text            = ordenVenta.direccion;
            List <string> telefono = new List <string>();

            if (!String.IsNullOrEmpty(ordenVenta.convencional))
            {
                telefono.Add(ordenVenta.convencional);
            }
            if (!String.IsNullOrEmpty(ordenVenta.celular))
            {
                telefono.Add(ordenVenta.celular);
            }
            dtpFechaFactura.Value = Program.fechaHora;
            txtTelefono.Text      = String.Join(", ", telefono);

            dgvOrdenVentaDetalle.DataSource = ordenVenta.tbOrdenVentaDetalle.Where(x => x.estadoRegistro).Select(y => new
            {
                cantidad      = y.cantidad,
                descripcion   = y.tbProducto.descripcion,
                precio        = (ordenVenta.idFormaPago == 1 ? (ordenVenta.tipoVenta == "N" ? y.precioOferta : y.costo) : y.precioVentaPublico),
                subTotalBruto = y.subTotalBruto
            }).ToList();

            txtSubtotal.Text = Util.FormatoMoneda(ordenVenta.subTotalBruto, 2);
            txtIVA.Text      = Util.FormatoMoneda(ordenVenta.IVA, 2);
            txtTotal.Text    = Util.FormatoMoneda(ordenVenta.totalNeto, 2);

            List <tbFormaPago> _tbFormaPago = (from FP in _dbCosolemEntities.tbFormaPago select FP).ToList();

            _tbFormaPago.Insert(0, new tbFormaPago {
                idFormaPago = 0, descripcion = "Seleccione"
            });
            cmbFormaPago.DataSource    = _tbFormaPago;
            cmbFormaPago.ValueMember   = "idFormaPago";
            cmbFormaPago.DisplayMember = "descripcion";

            if (ordenVenta.tbOrdenVentaFinanciacion.Any())
            {
                tbOrdenVentaFinanciacion ordenVentaFinanciacion = ordenVenta.tbOrdenVentaFinanciacion.FirstOrDefault();
                if (ordenVentaFinanciacion.valorCuotaInicialExigible > 0)
                {
                    AgregarFormaPago(1, ordenVentaFinanciacion.valorCuotaInicialExigible);
                }
            }
            dgvOrdenVentaFormaPago.DataSource = _BindingListtbOrdenVentaFormaPago;

            CalcularTotales();
        }
Exemplo n.º 14
0
        /// <summary>
        /// manda a guardar los datos
        /// </summary>
        /// <returns></returns>
        private bool guardar()
        {
            bool isOK = false;

            if (validarCampos())
            {
                tbEmpleado empleado = new tbEmpleado();
                tbPersona  persona  = new tbPersona();
                //banderaValida = true;

                try
                {
                    persona.tipoId = (int)cbotipoId.SelectedValue;
                    if (persona.tipoId == (byte)Enums.TipoId.Fisica)
                    {
                        persona.identificacion = mskId.Text.Trim();
                    }
                    //else
                    //{
                    //    persona.identificacion = txtId.Text.Trim();
                    //}
                    persona.nombre            = txtNombre.Text.Trim().ToUpper();
                    persona.apellido1         = txtApellido1.Text.Trim().ToUpper();
                    persona.apellido2         = txtApellido2.Text.Trim().ToUpper();
                    persona.fechaNac          = dtpFechaNac.Value;
                    persona.telefono          = int.Parse(mskTelefono.Text);
                    persona.codigoPaisTel     = "506";
                    persona.correoElectronico = txtCorreo.Text;
                    if (rbtmasc.Checked == true)
                    {
                        persona.sexo = 1;
                    }
                    else if (rbtfem.Checked == true)
                    {
                        persona.sexo = 2;
                    }

                    empleado.tipoId        = persona.tipoId;
                    empleado.id            = persona.identificacion;
                    empleado.fecha_ingreso = dtpFecha_Ingreso.Value;
                    empleado.idPuesto      = (int)cbxPustTrab.SelectedValue;


                    empleado.estado           = true;
                    empleado.fecha_ult_mod    = Utility.getDate();
                    empleado.fecha_crea       = Utility.getDate();
                    empleado.usuario_crea     = Global.Usuario.nombreUsuario;
                    empleado.usuario_ult_crea = Global.Usuario.nombreUsuario;
                    empleado.tbPersona        = persona;
                    empleado.direccion        = txtDireccion.Text;
                    empleado.esContraDefinido = !chkContradoFin.Checked;
                    if (empleado.esContraDefinido)
                    {
                        empleado.fecha_salida = dtpFecha_Salida.Value;
                    }
                    else
                    {
                        empleado.fecha_salida = null;
                    }

                    tbEmpleado empleados = empleadoIns.guardar(empleado);
                    isOK = true;
                    // txtId.Text = empleado.idPuesto.ToString();
                    MessageBox.Show("Los datos han sido almacenada en la base de datos.", "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (EntityExistException ex)
                {
                    MessageBox.Show(ex.Message);
                    isOK = false;
                }
                catch (EntityDisableStateException ex)
                {
                    DialogResult result = MessageBox.Show("Datos ya existe en la base datos, ¿Desea actualizarlos?", "Datos Existentes", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        empleadosGlo = empleado;
                        isOK         = modificar();
                    }
                    else
                    {
                        isOK = false;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    isOK = false;
                }
            }
            else
            {
                isOK = false;
            }
            return(isOK);
        }
Exemplo n.º 15
0
        private void frmCliente_Load(object sender, EventArgs e)
        {
            _dbCosolemEntities = new dbCosolemEntities();

            Util.ObtenerControles(this, typeof(TextBox)).ForEach(x =>
            {
                TextBox textBox = (TextBox)x;
                if (!textBox.Name.ToLower().Contains("correo"))
                {
                    textBox.CharacterCasing = CharacterCasing.Upper;
                }
            });

            tabControl1.SelectedTab = tabPage1;

            _tbPersona = new tbPersona {
                estadoRegistro = true, tbCliente = new tbCliente {
                    estadoRegistro = true
                }
            };
            _dbCosolemEntities.ObjectStateManager.ChangeObjectState(_tbPersona, EntityState.Detached);

            cmbTipoPersona.DataSource    = (from TP in _dbCosolemEntities.tbTipoPersona select new TipoPersona {
                idTipoPersona = TP.idTipoPersona, descripcion = TP.descripcion
            }).ToList();
            cmbTipoPersona.ValueMember   = "idTipoPersona";
            cmbTipoPersona.DisplayMember = "descripcion";
            cmbTipoPersona_SelectionChangeCommitted(null, null);

            txtNumeroIdentificacion.Clear();
            txtPrimerNombre.Clear();
            txtSegundoNombre.Clear();
            txtApellidoPaterno.Clear();
            txtApellidoMaterno.Clear();

            cmbSexo.DataSource    = (from S in _dbCosolemEntities.tbSexo select new { idSexo = S.idSexo, descripcion = S.descripcion }).ToList();
            cmbSexo.ValueMember   = "idSexo";
            cmbSexo.DisplayMember = "descripcion";

            dtpFechaNacimiento.Value = Program.fechaHora;

            cmbEstadoCivil.DataSource    = (from EC in _dbCosolemEntities.tbEstadoCivil select new { idEstadoCivil = EC.idEstadoCivil, descripcion = EC.descripcion }).ToList();
            cmbEstadoCivil.ValueMember   = "idEstadoCivil";
            cmbEstadoCivil.DisplayMember = "descripcion";

            txtCorreoElectronico.Clear();

            dgvDireccionesTelefonos.AutoGenerateColumns = false;
            _BindingListtbDireccion            = new BindingList <tbDireccion>(_tbPersona.tbDireccion.ToList());
            dgvDireccionesTelefonos.DataSource = _BindingListtbDireccion;

            var _tbTipoTelefono = (from TT in _dbCosolemEntities.tbTipoTelefono select new { idTipoTelefono = TT.idTipoTelefono, descripcion = TT.descripcion }).ToList();

            cmbTipoTelefono.DataSource    = _tbTipoTelefono;
            cmbTipoTelefono.ValueMember   = "idTipoTelefono";
            cmbTipoTelefono.DisplayMember = "descripcion";
            this._tbTipoTelefono          = _tbTipoTelefono.FirstOrDefault();

            var _tbOperadora = (from O in _dbCosolemEntities.tbOperadora select new { idOperadora = O.idOperadora, descripcion = O.descripcion }).ToList();

            cmbOperadora.DataSource    = _tbOperadora;
            cmbOperadora.ValueMember   = "idOperadora";
            cmbOperadora.DisplayMember = "descripcion";
            this._tbOperadora          = _tbOperadora.FirstOrDefault();

            dgvTelefonosPersonales.AutoGenerateColumns = false;
            _BindingListtbTelefonoPersonal             = new BindingList <tbTelefonoPersonal>(_tbPersona.tbTelefonoPersonal.ToList());
            dgvTelefonosPersonales.DataSource          = _BindingListtbTelefonoPersonal;

            txtNumeroIdentificacion.Select();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Manda a guardar a la capa Bussines
        /// </summary>
        /// <returns></returns>
        private bool guardar()
        {
            bool isOK = false;


            if (validarCampos())
            {
                tbPersona persona = new tbPersona();

                tbHorarioProveedor horarioPedido = new tbHorarioProveedor();
                tbHorarioProveedor horarioEntreg = new tbHorarioProveedor();

                tbProveedores proveedor = new tbProveedores();
                persona.tipoId = tipoIdGlobal;

                try
                {
                    if (tipoIdGlobal == 1)
                    {
                        persona.identificacion = mskCedula.Text;
                    }


                    else if (tipoIdGlobal == 2)
                    {
                        persona.identificacion = txtID.Text;
                    }
                    else
                    {
                        persona.identificacion = txtIdEmpresa.Text;
                    }


                    persona.apellido1         = txtApell1.Text.ToUpper().Trim();
                    persona.apellido2         = txtApell2.Text.ToUpper().Trim();
                    persona.correoElectronico = txtCorreo.Text.ToUpper().Trim();
                    persona.nombre            = txtNombre.Text.ToUpper().Trim();
                    persona.telefono          = int.Parse(mskTel.Text);



                    proveedor.id     = persona.identificacion;
                    proveedor.tipoId = persona.tipoId;

                    ////ToUpper() guarda todo en la base de datos en mayúscula
                    //proveedor.representante = txtRepresentante.Text.ToUpper().Trim();
                    //proveedor.telefono1     = mskTel.Text;
                    //proveedor.telefono2     = mskTel2.Text;

                    //proveedor.cuenta        = txtCuentaBanco.Text.Trim();
                    //proveedor.tipoPago      = int.Parse(cboTipoPago.Text.Substring(0, 1));
                    //proveedor.estado        = true;



                    proveedor.fecha_crea      = Utility.getDate();
                    proveedor.fecha_ult_mod   = Utility.getDate();
                    proveedor.usuario_crea    = Global.Usuario.nombreUsuario;
                    proveedor.usuario_ult_mod = Global.Usuario.nombreUsuario;


                    //horarios pedido
                    horarioPedido.idTipo      = proveedor.tipoId;
                    horarioPedido.idProveedor = proveedor.id;

                    horarioPedido.idTipoHorario = 1;
                    horarioPedido.lunes         = chkPedLunes.Checked;
                    horarioPedido.martes        = chkPedMartes.Checked;
                    horarioPedido.miercoles     = chkPedMiercoles.Checked;
                    horarioPedido.jueves        = chkPedJueves.Checked;
                    horarioPedido.viernes       = chkPedViernes.Checked;
                    horarioPedido.sabado        = chkPedSabado.Checked;
                    horarioPedido.domingo       = chkPedDomingo.Checked;

                    //horarios entrega

                    horarioEntreg.idTipo        = proveedor.tipoId;
                    horarioEntreg.idProveedor   = proveedor.id;
                    horarioEntreg.idTipoHorario = 2;
                    horarioEntreg.lunes         = chkEntregaL.Checked;
                    horarioEntreg.martes        = chkEntregaK.Checked;
                    horarioEntreg.miercoles     = chkEntregaM.Checked;
                    horarioEntreg.jueves        = chkEntregaJ.Checked;
                    horarioEntreg.viernes       = chkEntregaV.Checked;
                    horarioEntreg.sabado        = chkEntregaS.Checked;
                    horarioEntreg.domingo       = chkEntregaD.Checked;

                    List <tbHorarioProveedor> listaHorario = new List <tbHorarioProveedor>();

                    listaHorario.Add(horarioPedido);
                    listaHorario.Add(horarioEntreg);

                    proveedor.tbPersona          = persona;
                    proveedor.tbHorarioProveedor = listaHorario;
                    tbProveedores guardo = proveedorIns.guardar(proveedor);
                    isOK = true;



                    MessageBox.Show("Los datos se guardaron correctamente", "Éxito al guardar el proveedor", MessageBoxButtons.OK);
                }
                catch (EntityExistException ex)

                {
                    DialogResult result = MessageBox.Show("El proveedor ya existe.Desea activarlo?", ex.Message, MessageBoxButtons.YesNo);
                    //revisar///////////////


                    if (result == DialogResult.Yes)
                    {
                        chkEstado.Checked = true;
                        proveedorGlobal   = proveedor;
                        isOK = modificar();
                    }
                    else
                    {
                        isOK = false;
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    isOK = false;
                }
            }

            else
            {
                isOK = false;
            }


            return(isOK);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Manda a la  capa de Bussines a modificar
        /// </summary>
        /// <returns></returns>
        private bool modificar()
        {
            bool      isOK    = false;
            tbPersona persona = new tbPersona();

            tipoIdGlobal = proveedorGlobal.tipoId;


            proveedorGlobal.tbPersona.nombre    = txtNombre.Text.ToUpper().Trim();
            proveedorGlobal.tbPersona.apellido1 = txtApell1.Text.ToUpper().Trim();
            proveedorGlobal.tbPersona.apellido2 = txtApell2.Text.ToUpper().Trim();
            //proveedorGlobal.representante       = txtRepresentante.Text.ToUpper().Trim();
            //proveedorGlobal.telefono1           = mskTel.Text;
            //proveedorGlobal.telefono2           = mskTel2.Text;
            //proveedorGlobal.cuenta              = txtCuentaBanco.Text.Trim();
            //proveedorGlobal.tbPersona.correoElectronico    = txtCorreo.Text.Trim();
            //proveedorGlobal.tipoPago            = int.Parse(cboTipoPago.Text.Substring(0,1));

            ////estos if son para modificar el tipo de pago si no es transaccional limpia en la base de datos el campo cuenta
            //if (cboTipoPago.Text.Substring(0,1)== "1")
            //{
            //    proveedorGlobal.cuenta = string.Empty;
            //    txtCuentaBanco.Text = string.Empty;
            //}

            //if (cboTipoPago.Text.Substring(0, 1) == "2")
            //{
            //    proveedorGlobal.cuenta = string.Empty;
            //    txtCuentaBanco.Text = string.Empty;
            //}

            //if (cboTipoPago.Text.Substring(0, 1) == "3")
            //{
            //    proveedorGlobal.cuenta = string.Empty;
            //    txtCuentaBanco.Text = string.Empty;
            //}

            //////////auditoría/////
            proveedorGlobal.fecha_ult_mod   = Utility.getDate();
            proveedorGlobal.usuario_ult_mod = Global.Usuario.nombreUsuario;

            if (chkEstado.Checked)
            {
                proveedorGlobal.estado = true;
            }
            else
            {
                proveedorGlobal.estado = false;
            }
            //horarios pedido
            tbHorarioProveedor itemH = new tbHorarioProveedor();

            foreach (tbHorarioProveedor item in proveedorGlobal.tbHorarioProveedor)
            {
                if (item.idTipoHorario == 1)
                {
                    item.lunes     = chkPedLunes.Checked;
                    item.martes    = chkPedMartes.Checked;
                    item.miercoles = chkPedMiercoles.Checked;
                    item.jueves    = chkPedJueves.Checked;
                    item.viernes   = chkPedViernes.Checked;
                    item.sabado    = chkPedSabado.Checked;
                    item.domingo   = chkPedDomingo.Checked;
                }
                //Se cargan los dias de entrega
                else if (item.idTipoHorario == 2)
                {
                    item.lunes     = chkEntregaL.Checked;
                    item.martes    = chkEntregaK.Checked;
                    item.miercoles = chkEntregaM.Checked;
                    item.jueves    = chkEntregaJ.Checked;
                    item.viernes   = chkEntregaV.Checked;
                    item.sabado    = chkEntregaS.Checked;
                    item.domingo   = chkEntregaD.Checked;
                }
            }



            tbProveedores isProcess = proveedorIns.Modificar(proveedorGlobal);

            if (isProcess == null)
            {
                MessageBox.Show("Los datos no fueron modificados");
            }
            else
            {
                isOK = true;
                MessageBox.Show("¡Los datos fueron modificados correctamente!", "Éxito al modificar el proveedor", MessageBoxButtons.OK);
            }



            return(isOK);
        }
Exemplo n.º 18
0
        private void tsbGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                long        idTecnico      = ((Tecnico)cmbTecnicoAsignado.SelectedItem).idEmpleado;
                TipoPersona _tbTipoPersona = (TipoPersona)cmbTipoPersona.SelectedItem;

                string mensaje = String.Empty;
                if (String.IsNullOrEmpty(txtNumeroIdentificacion.Text.Trim()))
                {
                    mensaje += "Ingrese número de identificación\n";
                }
                if (_tbTipoPersona.idTipoPersona == 1)
                {
                    if (String.IsNullOrEmpty(txtPrimerNombre.Text.Trim()))
                    {
                        mensaje += "Ingrese primer nombre\n";
                    }
                    if (String.IsNullOrEmpty(txtApellidoPaterno.Text.Trim()))
                    {
                        mensaje += "Ingrese apellido paterno\n";
                    }
                    if (String.IsNullOrEmpty(txtApellidoMaterno.Text.Trim()))
                    {
                        mensaje += "Ingrese apellido materno\n";
                    }
                }
                if (_tbTipoPersona.idTipoPersona == 2)
                {
                    if (String.IsNullOrEmpty(txtRazonSocial.Text.Trim()))
                    {
                        mensaje += "Ingrese razón social\n";
                    }
                }
                if (String.IsNullOrEmpty(txtCorreoElectronico.Text.Trim()))
                {
                    mensaje += "Ingrese correo electrónico\n";
                }
                if (!String.IsNullOrEmpty(txtCorreoElectronico.Text.Trim()))
                {
                    if (!Util.ValidaEmail(txtCorreoElectronico.Text.Trim()))
                    {
                        mensaje += "Correo electrónico inválido, favor verificar\n";
                    }
                }
                if (String.IsNullOrEmpty(txtDireccionCliente.Text.Trim()))
                {
                    mensaje += "Ingrese dirección\n";
                }
                if (String.IsNullOrEmpty(txtConvencional.Text.Trim()) && String.IsNullOrEmpty(txtCelular.Text.Trim()))
                {
                    mensaje += "Ingrese al menos 1 teléfono\n";
                }
                if (txtCodigoProducto.Tag == null)
                {
                    mensaje += "Seleccione un producto\n";
                }
                if (String.IsNullOrEmpty(txtSerie.Text.Trim()))
                {
                    mensaje += "Ingrese serie del producto\n";
                }

                if (String.IsNullOrEmpty(mensaje.Trim()))
                {
                    tbPersona persona = null;

                    long idPersona = 0;
                    if (txtNumeroIdentificacion.Tag != null)
                    {
                        idPersona = Convert.ToInt64(txtNumeroIdentificacion.Tag);

                        persona = (from P in _dbCosolemEntities.tbPersona where P.idPersona == idPersona select P).FirstOrDefault();
                    }
                    else
                    {
                        int    idTipoPersona        = ((TipoPersona)cmbTipoPersona.SelectedItem).idTipoPersona;
                        int    idTipoIdentificacion = ((TipoIdentificacion)cmbTipoIdentificacion.SelectedItem).idTipoIdentificacion;
                        string numeroIdentificacion = txtNumeroIdentificacion.Text.Trim();

                        persona = (from P in _dbCosolemEntities.tbPersona where P.idTipoPersona == idTipoPersona && P.idTipoIdentificacion == idTipoIdentificacion && P.numeroIdentificacion == numeroIdentificacion select P).FirstOrDefault();
                    }

                    if (persona == null)
                    {
                        persona = new tbPersona
                        {
                            idTipoPersona        = ((TipoPersona)cmbTipoPersona.SelectedItem).idTipoPersona,
                            idTipoIdentificacion = ((TipoIdentificacion)cmbTipoIdentificacion.SelectedItem).idTipoIdentificacion,
                            numeroIdentificacion = txtNumeroIdentificacion.Text.Trim(),
                            primerNombre         = txtPrimerNombre.Text.Trim(),
                            segundoNombre        = txtSegundoNombre.Text.Trim(),
                            apellidoPaterno      = txtApellidoPaterno.Text.Trim(),
                            apellidoMaterno      = txtApellidoMaterno.Text.Trim(),
                            razonSocial          = txtRazonSocial.Text.Trim(),
                            idSexo            = 3,
                            idEstadoCivil     = 6,
                            correoElectronico = txtCorreoElectronico.Text.Trim(),
                            estadoRegistro    = true,
                            fechaHoraIngreso  = Program.fechaHora,
                            idUsuarioIngreso  = idUsuario,
                            terminalIngreso   = Program.terminal
                        };
                        persona.tbDireccion.Add(new tbDireccion
                        {
                            idCanton          = ((dynamic)cmbCantonCliente.SelectedItem).idCanton,
                            idTipoDireccion   = 1,
                            direccionCompleta = txtDireccionCliente.Text,
                            esPrincipal       = true,
                            estadoRegistro    = true,
                            fechaHoraIngreso  = Program.fechaHora,
                            idUsuarioIngreso  = idUsuario,
                            terminalIngreso   = Program.terminal
                        });
                        if (!String.IsNullOrEmpty(txtConvencional.Text.Trim()))
                        {
                            persona.tbDireccion.FirstOrDefault().tbTelefono.Add(new tbTelefono
                            {
                                idTipoTelefono   = 1,
                                idOperadora      = 1,
                                numero           = txtConvencional.Text.Trim(),
                                esPrincipal      = false,
                                estadoRegistro   = true,
                                fechaHoraIngreso = Program.fechaHora,
                                idUsuarioIngreso = idUsuario,
                                terminalIngreso  = Program.terminal
                            });
                        }
                        if (!String.IsNullOrEmpty(txtCelular.Text.Trim()))
                        {
                            persona.tbDireccion.FirstOrDefault().tbTelefono.Add(new tbTelefono
                            {
                                idTipoTelefono   = 2,
                                idOperadora      = 1,
                                numero           = txtCelular.Text.Trim(),
                                esPrincipal      = false,
                                estadoRegistro   = true,
                                fechaHoraIngreso = Program.fechaHora,
                                idUsuarioIngreso = idUsuario,
                                terminalIngreso  = Program.terminal
                            });
                        }
                        _dbCosolemEntities.tbPersona.AddObject(persona);
                        _dbCosolemEntities.SaveChanges();
                    }
                    else
                    {
                        persona.primerNombre                = txtPrimerNombre.Text.Trim();
                        persona.segundoNombre               = txtSegundoNombre.Text.Trim();
                        persona.apellidoPaterno             = txtApellidoPaterno.Text.Trim();
                        persona.apellidoMaterno             = txtApellidoMaterno.Text.Trim();
                        persona.razonSocial                 = txtRazonSocial.Text.Trim();
                        persona.correoElectronico           = txtCorreoElectronico.Text.Trim();
                        persona.fechaHoraUltimaModificacion = Program.fechaHora;
                        persona.idUsuarioUltimaModificacion = idUsuario;
                        persona.terminalUltimaModificacion  = Program.terminal;
                        long idDireccion = 0;
                        if (txtDireccionCliente.Tag != null)
                        {
                            idDireccion = Convert.ToInt64(txtDireccionCliente.Tag);
                        }
                        tbDireccion _tbDireccion = persona.tbDireccion.Where(x => x.idDireccion == idDireccion).FirstOrDefault();
                        if (_tbDireccion == null)
                        {
                            _tbDireccion                   = new tbDireccion();
                            _tbDireccion.idCanton          = ((dynamic)cmbCantonCliente.SelectedItem).idCanton;
                            _tbDireccion.idTipoDireccion   = 1;
                            _tbDireccion.direccionCompleta = txtDireccionCliente.Text;
                            _tbDireccion.esPrincipal       = true;
                            _tbDireccion.estadoRegistro    = true;
                            _tbDireccion.fechaHoraIngreso  = Program.fechaHora;
                            _tbDireccion.idUsuarioIngreso  = idUsuario;
                            _tbDireccion.terminalIngreso   = Program.terminal;
                        }
                        else
                        {
                            _tbDireccion.idCanton                    = ((dynamic)cmbCantonCliente.SelectedItem).idCanton;
                            _tbDireccion.direccionCompleta           = txtDireccionCliente.Text;
                            _tbDireccion.fechaHoraUltimaModificacion = Program.fechaHora;
                            _tbDireccion.idUsuarioUltimaModificacion = idUsuario;
                            _tbDireccion.terminalUltimaModificacion  = Program.terminal;
                        }
                        if (!String.IsNullOrEmpty(txtConvencional.Text.Trim()))
                        {
                            long idTelefonoConvencional = 0;
                            if (txtConvencional.Tag != null)
                            {
                                idTelefonoConvencional = Convert.ToInt64(txtConvencional.Tag);
                            }
                            tbTelefono _tbTelefonoConvencional = _tbDireccion.tbTelefono.Where(x => x.idTelefono == idTelefonoConvencional).FirstOrDefault();
                            if (_tbTelefonoConvencional == null)
                            {
                                _tbTelefonoConvencional = new tbTelefono();
                                _tbTelefonoConvencional.idTipoTelefono   = 1;
                                _tbTelefonoConvencional.idOperadora      = 1;
                                _tbTelefonoConvencional.numero           = txtConvencional.Text.Trim();
                                _tbTelefonoConvencional.esPrincipal      = false;
                                _tbTelefonoConvencional.estadoRegistro   = true;
                                _tbTelefonoConvencional.fechaHoraIngreso = Program.fechaHora;
                                _tbTelefonoConvencional.idUsuarioIngreso = idUsuario;
                                _tbTelefonoConvencional.terminalIngreso  = Program.terminal;
                            }
                            else
                            {
                                _tbTelefonoConvencional.numero = txtConvencional.Text.Trim();
                                _tbTelefonoConvencional.fechaHoraUltimaModificacion = Program.fechaHora;
                                _tbTelefonoConvencional.idUsuarioUltimaModificacion = idUsuario;
                                _tbTelefonoConvencional.terminalUltimaModificacion  = Program.terminal;
                            }
                            if (_tbTelefonoConvencional.EntityState == EntityState.Detached)
                            {
                                _tbDireccion.tbTelefono.Add(_tbTelefonoConvencional);
                            }
                        }
                        if (!String.IsNullOrEmpty(txtCelular.Text.Trim()))
                        {
                            long idTelefonoCelular = 0;
                            if (txtCelular.Tag != null)
                            {
                                idTelefonoCelular = Convert.ToInt64(txtCelular.Tag);
                            }
                            tbTelefono _tbTelefonoCelular = _tbDireccion.tbTelefono.Where(x => x.idTelefono == idTelefonoCelular).FirstOrDefault();
                            if (_tbTelefonoCelular == null)
                            {
                                _tbTelefonoCelular = new tbTelefono();
                                _tbTelefonoCelular.idTipoTelefono   = 2;
                                _tbTelefonoCelular.idOperadora      = 1;
                                _tbTelefonoCelular.numero           = txtCelular.Text.Trim();
                                _tbTelefonoCelular.esPrincipal      = false;
                                _tbTelefonoCelular.estadoRegistro   = true;
                                _tbTelefonoCelular.fechaHoraIngreso = Program.fechaHora;
                                _tbTelefonoCelular.idUsuarioIngreso = idUsuario;
                                _tbTelefonoCelular.terminalIngreso  = Program.terminal;
                            }
                            else
                            {
                                _tbTelefonoCelular.numero = txtCelular.Text.Trim();
                                _tbTelefonoCelular.fechaHoraUltimaModificacion = Program.fechaHora;
                                _tbTelefonoCelular.idUsuarioUltimaModificacion = idUsuario;
                                _tbTelefonoCelular.terminalUltimaModificacion  = Program.terminal;
                            }
                            if (_tbTelefonoCelular.EntityState == EntityState.Detached)
                            {
                                _tbDireccion.tbTelefono.Add(_tbTelefonoCelular);
                            }
                        }
                        if (_tbDireccion.EntityState == EntityState.Detached)
                        {
                            persona.tbDireccion.Add(_tbDireccion);
                        }
                    }
                    if (persona.tbCliente == null)
                    {
                        persona.tbCliente = new tbCliente
                        {
                            estadoRegistro   = true,
                            fechaHoraIngreso = Program.fechaHora,
                            idUsuarioIngreso = idUsuario,
                            terminalIngreso  = Program.terminal
                        };
                    }
                    else
                    {
                        persona.tbCliente.fechaHoraUltimaModificacion = Program.fechaHora;
                        persona.tbCliente.idUsuarioUltimaModificacion = idUsuario;
                        persona.tbCliente.terminalUltimaModificacion  = Program.terminal;
                    }

                    tbOrdenTrabajo ordenTrabajo = new tbOrdenTrabajo {
                        estadoRegistro = true, fechaHoraIngreso = Program.fechaHora, idUsuarioIngreso = idUsuario, terminalIngreso = Program.terminal
                    };

                    if (idOrdenTrabajo != 0)
                    {
                        ordenTrabajo = (from OT in _dbCosolemEntities.tbOrdenTrabajo where OT.idOrdenTrabajo == idOrdenTrabajo select OT).FirstOrDefault();
                        ordenTrabajo.fechaHoraUltimaModificacion = Program.fechaHora;
                        ordenTrabajo.idUsuarioUltimaModificacion = idUsuario;
                        ordenTrabajo.terminalUltimaModificacion  = Program.terminal;
                    }

                    ordenTrabajo.idEmpresa            = idEmpresa;
                    ordenTrabajo.idCliente            = persona.tbCliente.idCliente;
                    ordenTrabajo.tipoIdentificacion   = persona.tbTipoIdentificacion.descripcion;
                    ordenTrabajo.numeroIdentificacion = persona.numeroIdentificacion;
                    ordenTrabajo.cliente               = persona.nombreCompleto;
                    ordenTrabajo.direccion             = txtDireccionCliente.Text;
                    ordenTrabajo.convencional          = (!String.IsNullOrEmpty(txtConvencional.Text.Trim()) ? txtConvencional.Text.Trim() : null);
                    ordenTrabajo.celular               = (!String.IsNullOrEmpty(txtCelular.Text.Trim()) ? txtCelular.Text.Trim() : null);
                    ordenTrabajo.correoElectronico     = persona.correoElectronico;
                    ordenTrabajo.fechaHoraOrdenTrabajo = (dtpFechaHoraAgendamiento.Checked ? dtpFechaHoraAgendamiento.Value : (DateTime?)null);
                    ordenTrabajo.idTecnico             = (idTecnico == 0 ? (long?)null : idTecnico);
                    ordenTrabajo.idEstadoOrdenTrabajo  = (ordenTrabajo.fechaHoraOrdenTrabajo.HasValue && ordenTrabajo.idTecnico.HasValue ? 2 : 1);
                    ordenTrabajo.idProducto            = Convert.ToInt64(txtCodigoProducto.Tag);
                    ordenTrabajo.serie          = txtSerie.Text.Trim();
                    ordenTrabajo.fallaReportada = txtFallaReportada.Text.Trim();
                    if (ordenTrabajo.idOrdenTrabajo == 0)
                    {
                        _dbCosolemEntities.tbOrdenTrabajo.AddObject(ordenTrabajo);
                    }
                    _dbCosolemEntities.SaveChanges();
                    MessageBox.Show("Agendamiento de servicio técnico #" + ordenTrabajo.idOrdenTrabajo.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmAgendamientoServicioTecnico_Load(null, null);
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(mensaje, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                Util.MostrarException(this.Text, ex);
            }
        }
Exemplo n.º 19
0
        //Metodo guardar datos
        private bool guardar()
        {
            bool isOk = false;

            if (validarCampos())
            {
                tbPersona  persona = new tbPersona();
                tbUsuarios usuario = new tbUsuarios();

                try
                {
                    usuario.tipoId = (int)cboTipId.SelectedValue;
                    if (usuario.tipoId == (int)Enums.TipoId.Fisica)
                    {
                        usuario.id = mskId.Text;
                    }
                    else
                    {
                        usuario.id = txtId.Text;
                    }

                    usuario.nombreUsuario   = txtNomUsu.Text.Trim().ToUpper();
                    usuario.contraseña      = txtContra.Text.Trim().ToUpper();
                    usuario.idRol           = (int)cboIdRol.SelectedValue;
                    usuario.idTipoIdEmpresa = Global.Usuario.idTipoIdEmpresa;
                    usuario.idEmpresa       = Global.Usuario.idEmpresa;

                    persona.tipoId            = usuario.tipoId;
                    persona.identificacion    = usuario.id;
                    persona.nombre            = txtNombre.Text.Trim().ToUpper();
                    persona.apellido1         = txtApellido1.Text.Trim().ToUpper();
                    persona.apellido2         = txtApellido2.Text.Trim().ToUpper();
                    persona.fechaNac          = dtpFechNac.Value;
                    persona.telefono          = int.Parse(mskTelef.Text);
                    persona.correoElectronico = txtCorreo.Text.Trim().ToUpper();
                    persona.codigoPaisTel     = "506";

                    persona.provincia = cboProvincia.SelectedValue.ToString();
                    persona.canton    = cboCanton.SelectedValue.ToString();
                    persona.distrito  = cboDistrito.SelectedValue.ToString();
                    persona.barrio    = cboBarrios.SelectedValue.ToString();

                    persona.otrasSenas = txtOtrasSenas.Text;
                    if (rbtMasc.Checked)
                    {
                        persona.sexo = (int)Enums.Sexo.Masculino;
                    }
                    else if (rbtFem.Checked)
                    {
                        persona.sexo = (int)Enums.Sexo.Femenino;
                    }
                    //auditoría

                    usuario.estado          = true;
                    usuario.fecha_crea      = Utility.getDate();
                    usuario.fecha_ult_mod   = Utility.getDate();
                    usuario.usuario_crea    = Global.Usuario.nombreUsuario.Trim();
                    usuario.usuario_ult_mod = Global.Usuario.nombreUsuario.Trim();
                    usuario.tbPersona       = persona;

                    //Agrega imagen

                    //string destino = "C:\\Temp\\Usuario\\";
                    //string foto = "";
                    ////path = "";
                    //if (path != "")
                    //{
                    //    string nombre = Path.GetFileName(path);

                    //    foto = Path.Combine(destino, nombre);
                    //    usuario.foto_url = foto;
                    //}



                    ////Recuperamos la extension del archivo
                    //string ext =Path.GetExtension(path);

                    ////Unimos el numero de ID con la extension
                    //string nombreImagen = usuario.id.Trim() + ext;

                    ////Creamos el destino de la imagen.
                    //string destino = Path.Combine("C:\\temp\\Usuario\\",nombreImagen );


                    usuario = usuarioIns.guardar(usuario);

                    //if (usuario != null)
                    //{

                    //    if (path != "")
                    //    {
                    //        if (Directory.Exists(destino))
                    //        {

                    //            File.Copy(path, foto);


                    //        }
                    //        else
                    //        {



                    //            Directory.CreateDirectory(destino);

                    //            File.Copy(path, foto);

                    //        }

                    //    }
                    //}

                    //Copiamos la imagen con el nombre nuevo, en su destino establecido.


                    txtId.Text = usuario.id.ToString();
                    isOk       = true;

                    MessageBox.Show("¡Datos guardados correctamente!", "Exito al guardar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (EntityExistException ex)
                {
                    MessageBox.Show(ex.Message, "El usuario ya existe");
                    isOk = false;
                }
                catch (EntityDisableStateException ex)
                {
                    DialogResult result = MessageBox.Show(ex.Message, "El usuario ya existe", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        usuarioGlobal = usuario;
                        isOk          = modificar();
                    }
                    else
                    {
                        isOk = false;
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            else
            {
                isOk = false;
            }
            return(isOk);
        }
Exemplo n.º 20
0
        private bool guardarProveedor()
        {//SE CREAN LAS INSTANCIAS
            tbProveedores proveedor = new tbProveedores();
            tbPersona     persona   = new tbPersona();
            bool          processOk = false;

            try
            {
                if (validarCampos() == true)
                {//SE VALIDAN LOS CAMPOS OBLIGATORIOS...
                 // SE LLENAN LOS DATOS DE PERSONA PRIMERO... PRIMERO SE ES PERSONA Y LUEGO CLIENTE...
                    persona.tipoId = (int)cbotipoId.SelectedValue;


                    if ((int)cbotipoId.SelectedValue != (int)Enums.TipoId.Juridica)
                    {
                        persona.identificacion = mskidentificacion.Text.Trim();
                        persona.apellido1      = txtapellido1.Text.ToUpper().Trim();
                        persona.apellido2      = txtapellido2.Text.ToUpper().Trim();
                        persona.fechaNac       = DateTime.Parse(dtpfechaNa.Text);
                        if (rbtmasc.Checked)
                        {
                            persona.sexo = 1;
                        }
                        else
                        {
                            persona.sexo = 2;
                        }
                    }
                    else
                    {
                        persona.identificacion = txtidentificacion.Text.Trim();
                    }
                    persona.nombre = txtnombre.Text.ToUpper().Trim();


                    persona.correoElectronico = txtContactoProv.Text.Trim();
                    persona.telefono          = int.Parse(msktelefono.Text);

                    persona.provincia     = cboProvincia.SelectedValue.ToString();
                    persona.canton        = cboCanton.SelectedValue.ToString();
                    persona.distrito      = cboDistrito.SelectedValue.ToString();
                    persona.codigoPaisTel = "506";
                    persona.otrasSenas    = txtOtrasSenas.Text;
                    persona.barrio        = cboBarrios.SelectedValue.ToString();

                    // AQUI ES DONDE QUE ESA PERSONA TAMBIEN ES CLIENTE...
                    proveedor.tbPersona = persona;
                    proveedor.id        = persona.identificacion;
                    proveedor.tipoId    = persona.tipoId;

                    proveedor.fax               = mskFax.Text;
                    proveedor.descripcion       = txtObserv.Text;
                    proveedor.cuentaBancaria    = txtCuentaBanco.Text;
                    proveedor.contactoProveedor = txtContactoProv.Text.ToUpper().Trim();

                    proveedor.encargadoConta   = txtEncargadoTrib.Text.Trim();
                    proveedor.correoElectConta = txtCorreoContabilidad.Text;
                    proveedor.nombreTributario = txtNombreTribut.Text;



                    proveedor.estado          = true;
                    proveedor.fecha_crea      = Utility.getDate();
                    proveedor.fecha_ult_mod   = Utility.getDate();
                    proveedor.usuario_crea    = Global.Usuario.nombreUsuario;
                    proveedor.usuario_ult_mod = Global.Usuario.nombreUsuario;
                    // CON NUESTRA INSTACIA LLAMAMOS AL METODO GUARDAR.... Y LE MANDAMOS A CLIENTE...

                    proveedor = proveedorIns.guardar(proveedor);
                    processOk = true;
                    MessageBox.Show("Los datos han sido almacenada en la base de datos.", "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            catch (EntityDisableStateException ex)
            {
                //LOS CATCH EVITAN QUE LOS APLICATIVOS SE CAIGAN....
                DialogResult result = MessageBox.Show("Datos ya existe en la base datos, ¿Desea actualizarlos?", "Datos Existentes", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    proveedorGlobal = proveedor;
                    processOk       = actualizarProveedor();
                }
            }
            catch (EntityExistException ex)
            {
                MessageBox.Show(ex.Message);
                processOk = false;
            }
            catch (Exception ex)
            {
                // AQUI ES DONDE LAS EXCEPCIONES SON ATRAPADAS Y SE MUESTRA EL MENSAJE PERSONALIZADO...
                MessageBox.Show("Ha ocurrido un error. Comuniquese con el administrador " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                processOk = false;
            }

            return(processOk);
        }
Exemplo n.º 21
0
 public frmReporteGeneracionContrasena(tbPersona _tbPersona)
 {
     this._tbPersona = _tbPersona;
     InitializeComponent();
 }