Example #1
0
        /// <summary> Modifica un Cliente. </summary>
        /// <param name="tobjCliente"> Un objeto del tipo Cliente.</param>
        /// <returns> Un string que indica si se ejecuto o no la operación. </returns>
        public string gmtdEditar(tblCliente tobjCliente)
        {
            String strResultado;

            try
            {
                using (dbExequial2010DataContext cliente = new dbExequial2010DataContext())
                {
                    tblCliente cli_old = cliente.tblClientes.SingleOrDefault(p => p.strCodigoCli == tobjCliente.strCodigoCli);
                    cli_old.strCodigoCli   = tobjCliente.strCodigoCli;
                    cli_old.strContacto    = tobjCliente.strContacto;
                    cli_old.strCorreo      = tobjCliente.strCorreo;
                    cli_old.strDireccion   = tobjCliente.strDireccion;
                    cli_old.strEmpresa     = tobjCliente.strEmpresa;
                    cli_old.dtmFechaIng    = tobjCliente.dtmFechaIng;
                    cli_old.strTelefono    = tobjCliente.strTelefono;
                    cli_old.strTipoCliente = tobjCliente.strTipoCliente;
                    cli_old.strTipoDoc     = tobjCliente.strTipoDoc;
                    cliente.tblLogdeActividades.InsertOnSubmit(tobjCliente.log);
                    cliente.SubmitChanges();
                    strResultado = "Registro Actualizado";
                }
            }
            catch (Exception ex)
            {
                new dao().gmtdInsertarError(ex);
                strResultado = "- Ocurrió un error al Actualizar el registro";
            }
            return(strResultado);
        }
Example #2
0
        /// <summary> Consulta los datos de un determinado cliente. </summary>
        /// <param name="tstrCedulaCli"> La cédula del cliente a consultar. </param>
        /// <returns> Los datos del cliente consultado. </returns>
        public tblCliente gmtdConsultarDetalle(string tstrCodigoCli)
        {
            using (dbExequial2010DataContext clientes = new dbExequial2010DataContext())
            {
                var query = from cli in clientes.tblClientes
                            where cli.bitAnulado == false && cli.strCodigoCli == tstrCodigoCli
                            select cli;

                tblCliente cliente = new tblCliente();
                foreach (var dato in query.ToList())
                {
                    cliente.dtmFechaAnu    = dato.dtmFechaAnu;
                    cliente.dtmFechaIng    = dato.dtmFechaIng;
                    cliente.strCelular     = dato.strCelular;
                    cliente.strCodigoCli   = dato.strCodigoCli;
                    cliente.strContacto    = dato.strContacto;
                    cliente.strCorreo      = dato.strCorreo;
                    cliente.strDireccion   = dato.strDireccion;
                    cliente.strEmpresa     = dato.strEmpresa;
                    cliente.strTelefono    = dato.strTelefono;
                    cliente.strTipoCliente = dato.strTipoCliente;
                    cliente.strTipoDoc     = dato.strTipoDoc;
                }
                return(cliente);
            }
        }
Example #3
0
        /// <summary>Selecciona los clientes registrados cuya informacíón coicida con los campos de la clausula where. </summary>
        /// <param name="tobjcliente"> El objeto cliente con los datos para filtrar </param>
        /// <returns> Un lista con los clientes seleccionados. </returns>
        public IList <Cliente> gmtdFiltrar(tblCliente tobjcliente)
        {
            using (dbExequial2010DataContext clientes = new dbExequial2010DataContext())
            {
                var query = from cli in clientes.tblClientes
                            where cli.bitAnulado == false &&
                            cli.strCodigoCli.StartsWith(tobjcliente.strCodigoCli) &&
                            cli.strContacto.StartsWith(tobjcliente.strContacto) &&
                            cli.strEmpresa.StartsWith(tobjcliente.strEmpresa)
                            select cli;

                List <Cliente> lstClientes = new List <Cliente>();
                foreach (var dato in query.ToList())
                {
                    Cliente cli = new Cliente();
                    cli.strCodigoCli = dato.strCodigoCli;
                    cli.strContacto  = dato.strContacto;
                    cli.strCelular   = dato.strCelular;
                    cli.strEmpresa   = dato.strEmpresa;
                    cli.strTelefono  = dato.strTelefono;
                    lstClientes.Add(cli);
                }
                return(lstClientes);
            }
        }
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            var usu = (from usua in contexto.tblUsuario
                       where usua.strUsuario == txtCorreo.Text
                       select usua).FirstOrDefault();


            if (usu == null)
            {
                tblCliente cli = new tblCliente();
                cli.strNombre          = txtNombre.Text.ToUpper();
                cli.strApellidoP       = txtAPaterno.Text.ToUpper();
                cli.strApellidoM       = txtAMaterno.Text.ToUpper();
                cli.strSituacionFiscal = txtSituacion.Text;
                cli.strCorreo          = txtCorreo.Text;
                cli.strNumeroBodega    = txtNumeroBodega.Text;
                cli.strHorarioAtencion = txtHorario.Text;
                cli.strEncargado       = txtEncargador.Text.ToUpper();
                cli.strPagos           = txtPagos.Text.ToUpper();
                cli.strMetodoPago      = txtMetodoPago.Text;
                cli.strEstablecimiento = txtEstablecimiento.Text;
                cli.idActivo           = 1;
                ControllerCliente ctrlCli = new ControllerCliente();
                ctrlCli.InsertarCliente(GetDatosVista(cli));
                this.LimpiarCampos();
                this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "exito()", true);
            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "alerta()", true);
            }
        }
Example #5
0
        private void dgv_DoubleClick(object sender, EventArgs e)
        {
            tblCliente cliente = new tblCliente();
            DataGridViewSelectedRowCollection rows = ((DataGridView)sender).SelectedRows;

            foreach (DataGridViewRow dato in rows)
            {
                cliente = new blCliente().gmtdConsultarDetalle(dato.Cells[0].Value.ToString());
            }

            if (cliente.strContacto != null)
            {
                this.txtCodigo.Enabled    = false;
                this.txtCodigo.Text       = cliente.strCodigoCli;
                this.txtEmpresa.Text      = cliente.strEmpresa;
                this.txtContacto.Text     = cliente.strContacto;
                this.txtDireccion.Text    = cliente.strDireccion;
                this.txtTelefono.Text     = cliente.strTelefono;
                this.txtCelular.Text      = cliente.strCelular;
                this.txtMail.Text         = cliente.strCorreo;
                this.cboTipo.SelectedText = cliente.strTipoDoc;
                this.cboTipoTercero.Text  = cliente.strTipoCliente;
                this.dtpIngreso.Value     = cliente.dtmFechaIng;
            }
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblCliente tblCliente = db.tblClientes.Find(id);

            db.tblClientes.Remove(tblCliente);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private void Add()

        {
            if (this.txtPassword.Text != this.txtConfirmPassword.Text)
            {
                this.lblError.Text = "la Contraseña y la confirmación debe de ser Iguales";
                return;
            }


            Crypt _crypt = new Crypt();

            _password = _crypt.MD5(txtPassword.Text);


            FContext = new FacturadorEntities1();
            try
            {
                // ObjUsuario = FContext.TblUsuarios.Single(Usuario => Usuario.Username == txtUserName.Text && Usuario.Password == txtpassword.Text );

                var ObjUsuario = FContext.TblUsuarios.FirstOrDefault(Usuario => Usuario.CorreoElectronico == txtEmail.Text);

                if (ObjUsuario != null)
                {
                    var _usr = FContext.TblUsuarios.FirstOrDefault(usr => usr.CorreoElectronico == txtEmail.Text && usr.Password == _password);

                    if (_usr != null)
                    {
                        lblError.Text = "El Correo Ya existe: ";
                        lnkRecuperarPassword.Visible = true;
                    }
                }
                else
                {
                    tblCliente cliente = new tblCliente();

                    cliente.Nombre            = this.txtNombre.Text.ToUpper();
                    cliente.Empresa           = this.txtEmpresa.Text.ToUpper();
                    cliente.CorreoElectronico = this.txtEmail.Text;
                    cliente.FechaCreacion     = DateTime.Now;
                    cliente.Telefono          = this.txtTelefono.Text;
                    cliente.Password          = _password;
                    FContext.AddTotblClientes(cliente);

                    FContext.SaveChanges();
                    Session["IdCliente"] = cliente.pkClienteid;
                    CrearEmisor();
                    CreaUsuario();


                    Response.Redirect("listEmisores.aspx");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>Selecciona los clientes registrados cuya informacíón coicida con los campos de la clausula where. </summary>
        /// <param name="tobjCliente"> El objeto cliente con los datos para filtrar </param>
        /// <returns> Un lista con los clientes seleccionados. </returns>
        public IList <Cliente> gmtdFiltrar(tblCliente tobjCliente)
        {
            if (tobjCliente.strCodigoCli == "0")
            {
                tobjCliente.strCodigoCli = "";
            }

            return(new daoCliente().gmtdFiltrar(tobjCliente));
        }
 public ActionResult Edit([Bind(Include = "Id,nombre_compañia,direccion,telefono,email,ruta_imagen")] tblCliente tblCliente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblCliente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblCliente));
 }
Example #10
0
 public ActionResult Edit([Bind(Include = "IdCliente,NombreCliente,TelCliente,idDonde,ObsCliente,ActivoCliente")] tblCliente tblCliente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblCliente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idDonde = new SelectList(db.tblDondeNosConocios, "idDonde", "DesDonde", tblCliente.idDonde);
     return(View(tblCliente));
 }
        public ActionResult Create([Bind(Include = "Id,nombre_compañia,direccion,telefono,email,ruta_imagen")] tblCliente tblCliente)
        {
            if (ModelState.IsValid)
            {
                db.tblCliente.Add(tblCliente);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblCliente));
        }
        /// <summary> Inserta un cliente. </summary>
        /// <param name="tobjCliente"> Un objeto del tipo cliente. </param>
        /// <returns> Un string que indica si se ejecuto o no la operación. </returns>
        public string gmtdInsertar(tblCliente tobjCliente)
        {
            if (tobjCliente.dtmFechaIng == null)
            {
                return("- Debe de ingresar la fecha de ingreso.");
            }

            if (tobjCliente.strCodigoCli == "")
            {
                return("- Debe de ingresar el código del cliente. ");
            }

            if (tobjCliente.strContacto == "")
            {
                return("- Debe de ingresar el contacto donde el cliente. ");
            }

            if (tobjCliente.strDireccion == "")
            {
                return("- Debe de ingresar la dirección. ");
            }

            if (tobjCliente.strEmpresa == "")
            {
                return("- Debe de ingresar el nombre de la empresa o del cliente si es un particular. ");
            }

            if (tobjCliente.strTelefono == "")
            {
                return("- Debe de ingresar el número telefonico. ");
            }

            if (tobjCliente.strTipoDoc == "")
            {
                return("- Debe de ingresar el tipo de documento. ");
            }

            tblCliente cli = new daoCliente().gmtdConsultar(tobjCliente.strCodigoCli);

            if (cli.strCodigoCli == null)
            {
                tobjCliente.bitAnulado  = false;
                tobjCliente.dtmFechaAnu = Convert.ToDateTime("01/01/1900");
                tobjCliente.log         = metodos.gmtdLog("Ingresa el cliente " + tobjCliente.strCodigoCli, tobjCliente.strFormulario);
                return(new daoCliente().gmtdInsertar(tobjCliente));
            }
            else
            {
                return("- Este registro ya aparece ingresado.");
            }
        }
Example #13
0
        // GET: Clientes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblCliente tblCliente = db.tblClientes.Find(id);

            if (tblCliente == null)
            {
                return(HttpNotFound());
            }
            return(View(tblCliente));
        }
        private void Add()
        {
            Crypt _crypt = new Crypt();

            _password = _crypt.MD5(this.txtPassword.Text);


            FContext = new FacturadorEntities1();
            try
            {
                var ObjUsuario = FContext.TblUsuarios.FirstOrDefault(Usuario => Usuario.CorreoElectronico == txtEmail.Text);

                if (ObjUsuario != null)
                {
                    //var _usr = FContext.TblUsuarios.FirstOrDefault(usr => usr.CorreoElectronico == txtEmail.Text && usr.Password == _password);

                    //if (_usr != null)
                    //{
                    lblError.Text = "El Correo Ya existe: ";
                    lnkRecuperarPassword.Visible = true;

                    //}
                }
                else
                {
                    tblCliente cliente = new tblCliente();

                    cliente.Nombre            = this.txtNombre.Text.ToUpper();
                    cliente.Empresa           = this.txtEmpresa.Text.ToUpper();
                    cliente.CorreoElectronico = this.txtEmail.Text;
                    cliente.FechaCreacion     = DateTime.Now;
                    cliente.Telefono          = this.txtTelefono.Text;
                    cliente.Password          = _password;
                    FContext.AddTotblClientes(cliente);

                    FContext.SaveChanges();
                    Session["IdCliente"] = cliente.pkClienteid;
                    CrearEmisor();
                    CreaUsuario();


                    Response.Redirect("Desktop.aspx");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #15
0
        // GET: Clientes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblCliente tblCliente = db.tblClientes.Find(id);

            if (tblCliente == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idDonde = new SelectList(db.tblDondeNosConocios, "idDonde", "DesDonde", tblCliente.idDonde);
            return(View(tblCliente));
        }
Example #16
0
        /// <summary>
        /// Crea un objeto del tipo aplicación de acuerdo a la información de los texbox.
        /// </summary>
        /// <returns> Un objeto del tipo aplicación. </returns>
        private tblCliente crearObj()
        {
            tblCliente cliente = new tblCliente();

            cliente.dtmFechaIng    = this.dtpIngreso.Value;
            cliente.strCelular     = this.txtCelular.Text;
            cliente.strCodigoCli   = this.txtCodigo.Text;
            cliente.strContacto    = this.txtContacto.Text;
            cliente.strCorreo      = this.txtMail.Text;
            cliente.strDireccion   = this.txtDireccion.Text;
            cliente.strEmpresa     = this.txtEmpresa.Text;
            cliente.strFormulario  = this.Name;
            cliente.strTelefono    = this.txtTelefono.Text;
            cliente.strTipoCliente = this.cboTipoTercero.Text;
            cliente.strTipoDoc     = this.cboTipo.Text;
            return(cliente);
        }
Example #17
0
        public bool InsertarCliente(tblCliente _TBL_Cliente)
        {
            bool respuesta = false;

            try
            {
                contexto.tblCliente.InsertOnSubmit(_TBL_Cliente);
                contexto.SubmitChanges();
                respuesta = true;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
                respuesta = false;
            }
            return(respuesta);
        }
        /// <summary> Elimina un cliente de la base de datos. </summary>
        /// <param name="tobjCliente"> Un objeto del tipo tblCliente. </param>
        /// <returns> Un string que indica si se ejecuto o no el metodo. </returns>
        public String gmtdEliminar(tblCliente tobjCliente)
        {
            if (tobjCliente.strCodigoCli == "0")
            {
                return("- Debe de ingresar el código del ahorrador a eliminar.");
            }

            tblCliente aho = new daoCliente().gmtdConsultar(tobjCliente.strCodigoCli);

            if (aho.strCodigoCli == null)
            {
                return("- Este registro no aparece ingresado.");
            }
            else
            {
                tobjCliente.log = metodos.gmtdLog("Elimina el cliente " + tobjCliente.strCodigoCli, tobjCliente.strFormulario);
                return(new daoCliente().gmtdEliminar(tobjCliente));
            }
        }
Example #19
0
        /// <summary> Inserta un cliente. </summary>
        /// <param name="tobjCliente"> Un objeto del tipo tblCliente. </param>
        /// <returns> Un string que indica si se ejecuto o no la operación. </returns>
        public string gmtdInsertar(tblCliente tobjCliente)
        {
            String strRetornar;

            try
            {
                using (dbExequial2010DataContext cliente = new dbExequial2010DataContext())
                {
                    cliente.tblClientes.InsertOnSubmit(tobjCliente);
                    cliente.tblLogdeActividades.InsertOnSubmit(tobjCliente.log);
                    cliente.SubmitChanges();
                    strRetornar = "Registro Insertado";
                }
            }
            catch (Exception ex)
            {
                new dao().gmtdInsertarError(ex);
                strRetornar = "- Ocurrió un error al insertar el registro.";
            }
            return(strRetornar);
        }
        protected tblCliente GetDatosVista(tblCliente cli)
        {
            var EstaMuni = ddlMunicipio.SelectedItem.Value;
            var random   = new Random();
            var value    = random.Next(0, 999999);


            tblDireccion direccion = new tblDireccion();

            direccion.fkEstadoMunicipio = Int32.Parse(EstaMuni);
            direccion.strCalle          = txtCalle.Text.ToUpper();
            direccion.strColonia        = txtColonia.Text.ToUpper();
            direccion.intCodpost        = txtCodPos.Text;
            direccion.strNumInt         = txtNumInt.Text.ToUpper();
            direccion.strNumExt         = txtNumExt.Text.ToUpper();
            direccion.strReferencias    = txtReferencia.Text.ToUpper();

            tblTelefono telefono = new tblTelefono();

            telefono.strCelular = txtCelular.Text.ToUpper();
            telefono.strTelCasa = txtTelEncargador.Text.ToUpper();
            telefono.strOtro    = txtTelOtro.Text.ToUpper();

            tblUsuario login = new tblUsuario();

            login.strUsuario     = txtCorreo.Text;
            login.strPassword    = value.ToString();
            login.strTipousuario = "CLIENTE";
            login.idActivo       = 1;

            ControllerCliente ctrlClie = new ControllerCliente();

            //ctrlClie.enviarcorreo(cli.strCorreo, value.ToString());

            cli.tblDireccion = direccion;
            cli.tblTelefono  = telefono;
            cli.tblUsuario   = login;

            return(cli);
        }
        private void txtModificar_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                this.lblNombre.Text = "";

                switch (this.cboTipo.Text)
                {
                case "Agraciado":
                    agraciado           = new blAgraciado().gmtdConsultarDetalle(this.txtModificar.Text);
                    this.lblNombre.Text = agraciado.strNombreAgra + " " + agraciado.strApellido1Agra + " " + agraciado.strApellido2Agra;
                    break;

                case "Ahorrador":
                    ahorrador           = new blAhorrador().gmtdConsultarDetalle(this.txtModificar.Text);
                    this.lblNombre.Text = ahorrador.strNombreAho + " " + ahorrador.strApellido1Aho + " " + ahorrador.strApellido2Aho;
                    break;

                case "Cliente":
                    cliente             = new blCliente().gmtdConsultarDetalle(this.txtModificar.Text);
                    this.lblNombre.Text = cliente.strContacto;
                    break;

                case "Socio":
                    socio = new blSocio().gmtdConsultarDetalle(this.txtModificar.Text);
                    this.lblNombre.Text = socio.strNombreSoc + " " + socio.strApellido1Soc + " " + socio.strApellido2Soc;
                    break;
                }

                if (this.lblNombre.Text.Trim() == "")
                {
                    MessageBox.Show("Este número de cédula no aparece registrada como " + this.cboTipo.Text, "Cambiar Cédula", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                this.txtCambiar.Focus();
            }
        }
Example #22
0
        /// <summary> Elimina un cliente de la base de datos. </summary>
        /// <param name="tobjCliente"> Un objeto del tipo tblAhorradore. </param>
        /// <returns> Un string que indica si se ejecuto o no el metodo. </returns>
        public String gmtdEliminar(tblCliente tobjCliente)
        {
            String strResultado;

            try
            {
                using (dbExequial2010DataContext clientes = new dbExequial2010DataContext())
                {
                    tblCliente cli_old = clientes.tblClientes.SingleOrDefault(p => p.strCodigoCli == tobjCliente.strCodigoCli);
                    cli_old.bitAnulado  = true;
                    cli_old.dtmFechaAnu = DateTime.Now;

                    clientes.tblLogdeActividades.InsertOnSubmit(tobjCliente.log);
                    clientes.SubmitChanges();
                    strResultado = "Registro Eliminado";
                }
            }
            catch (Exception ex)
            {
                new dao().gmtdInsertarError(ex);
                strResultado = "- No se puede eliminar el registro.";
            }
            return(strResultado);
        }
 /// <summary> Modifica un cliente. </summary>
 /// <param name="tobjCliente"> Un objeto del tipo cliente.</param>
 /// <returns> Un string que indica si se ejecuto o no la operación. </returns>
 public string gmtdEditar(tblCliente tobjCliente)
 {
     return(new blCliente().gmtdEditar(tobjCliente));
 }
 /// <summary>Selecciona los clientes registrados cuya informacíón coicida con los campos de la clausula where. </summary>
 /// <param name="tobjCliente"> El objeto cliente con los datos para filtrar </param>
 /// <returns> Un lista con los clientes seleccionados. </returns>
 public IList <Cliente> gmtdFiltrar(tblCliente tobjCliente)
 {
     return(new blCliente().gmtdFiltrar(tobjCliente));
 }
 /// <summary> Elimina un cliente de la base de datos. </summary>
 /// <param name="tobjCliente"> Un objeto del tipo tblCliente. </param>
 /// <returns> Un string que indica si se ejecuto o no el metodo. </returns>
 public String gmtdEliminar(tblCliente tobjCliente)
 {
     return(new blCliente().gmtdEliminar(tobjCliente));
 }