예제 #1
0
        public SingleCliente(SaveAction action, Models.Clientes cliente)
        {
            InitializeComponent();
            currentAction = action;
            TypeInit();
            currentClient = cliente;

            textBox1.Text     = currentClient.Nombre;
            textBox3.Text     = currentClient.Cedula;
            comboBox1.Text    = (currentClient.TipoPersona == 1) ? "Persona Física" : "Persona Jurídica";
            textBox4.Text     = currentClient.NoTarjeta;
            textBox5.Text     = currentClient.LimiteCredito.ToString();
            checkBox1.Checked = currentClient.Estado;
            textBox1.Size     = new Size(508, 25);

            if (currentAction == SaveAction.Ver)
            {
                textBox1.Enabled  = false;
                textBox3.Enabled  = false;
                comboBox1.Enabled = false;
                textBox4.Enabled  = false;
                textBox5.Enabled  = false;
                checkBox1.Enabled = false;
                button1.Enabled   = false;
                button2.Text      = "Salir";
            }
        }
예제 #2
0
        private int guardarCliente()
        {
            Models.Clientes cliente;

            if ((cctbApellido.Text != string.Empty) && (cctbDireccion.Text != string.Empty))
            {
                using (MABEntities db = new MABEntities())
                {
                    cliente = new Models.Clientes();

                    cliente.nombre    = cctbNombre.Text;
                    cliente.apellido  = cctbApellido.Text;
                    cliente.direccion = cctbDireccion.Text;

                    db.Clientes.Add(cliente);
                    db.SaveChanges();

                    return(cliente.Id);
                }
            }
            else
            {
                MessageBox.Show("Faltan campos por completar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(-1);
        }
예제 #3
0
        private string clienteConMasReparaciones()
        {
            using (MABEntities db = new MABEntities())
            {
                int idCliente       = -1;
                int maxReparaciones = 0;
                foreach (Models.Clientes cliente in db.Clientes)
                {
                    int reparaciones = 0;

                    foreach (Models.Lavarropas lavarropa in cliente.Lavarropas)
                    {
                        reparaciones += lavarropa.Reparacion.Count();
                    }

                    if (reparaciones >= maxReparaciones)
                    {
                        maxReparaciones = reparaciones;
                        idCliente       = cliente.Id;
                    }
                }

                if (idCliente != -1)
                {
                    Models.Clientes c = db.Clientes.Find(idCliente);

                    return(c.nombre + ' ' + c.apellido);
                }
                else
                {
                    return("");
                }
            }
        }
예제 #4
0
        public string Post(Models.Clientes cli)
        {
            try
            {
                string query = String.Format(@"INSERT INTO `crmall_test`.`cliente`
                                                (
                                                nome_cliente,
                                                datanasc_cliente,
                                                sexo_cliente,
                                                cep_cliente,
                                                endereco_cliente,
                                                numero_cliente,
                                                bairro_cliente,
                                                estado_cliente,
                                                cidade_cliente)
                                                VALUES
                                                ('{0}','{1}',{2},'{3}','{4}','{5}','{6}','{7}','{8}'
                                                );", cli.nome_cliente, cli.datanasc_cliente.ToString("yyyy/MM/dd"), cli.sexo_cliente, cli.cep_cliente ?? string.Empty, cli.endereco_cliente ?? string.Empty, cli.numero_cliente ?? string.Empty, cli.bairro_cliente ?? string.Empty, cli.estado_cliente ?? string.Empty, cli.cidade_cliente ?? string.Empty);

                DataTable table = new DataTable();
                using (var con = new MySqlConnection(ConfigurationManager.ConnectionStrings["crmall_test"].ConnectionString))
                    using (var cmd = new MySqlCommand(query, con))
                        using (var da = new MySqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }
                return("Added Successfully");
            }
            catch (Exception e)
            {
                return("Falha em Adicionar : " + e.Message);
            }
        }
예제 #5
0
        public Boolean Borrar(int id)
        {
            bool exito = false;

            Models.Clientes cliente = new Models.Clientes();

            try
            {
                string Token  = HttpContext.Session.GetObjectFromJson <string>("SessionToken");
                string UserId = HttpContext.Session.GetObjectFromJson <string>("SessionUserID");

                if (Token != null)
                {
                    if (ClienteService.ValidateToken(Token, UserId))
                    {
                        cliente = ClienteService.Buscar(id);

                        if (cliente != null)
                        {
                            exito = ClienteService.Delete(cliente);
                        }
                    }
                }

                return(exito);
            }
            catch (Exception error)
            {
                return(false);
            }
        }
예제 #6
0
        private string clienteConMasLavarropas()
        {
            using (MABEntities db = new MABEntities())
            {
                int idCliente     = -1;
                int maxLavarropas = 0;
                foreach (Models.Clientes cliente in db.Clientes)
                {
                    int lavarropas = cliente.Lavarropas.Count();

                    if (lavarropas >= maxLavarropas)
                    {
                        maxLavarropas = lavarropas;
                        idCliente     = cliente.Id;
                    }
                }

                if (idCliente != -1)
                {
                    Models.Clientes c = db.Clientes.Find(idCliente);
                    return(c.nombre + " " + c.apellido);
                }
                else
                {
                    return("");
                }
            }
        }
        public ActionResult BubbleSort_Apellidos()
        {
            try
            {
                for (int i = 0; i < Singleton.Instance.ClientesList.Count; i++)
                {
                    for (int j = i + 1; j < Singleton.Instance.ClientesList.Count; j++)
                    {
                        var  aux      = new Models.Clientes();
                        Char Iniciali = Convert.ToChar(Singleton.Instance.ClientesList[i].Apellido.Substring(0, 1));  //Inicial del nombre comparado
                        Char Inicialj = Convert.ToChar(Singleton.Instance.ClientesList[j].Apellido.Substring(0, 1));  //Inicial del nombre a comparar


                        if (Iniciali > Inicialj)
                        {
                            aux = Singleton.Instance.ClientesList[i];
                            Singleton.Instance.ClientesList[i] = Singleton.Instance.ClientesList[j];
                            Singleton.Instance.ClientesList[j] = aux;
                        }
                    }
                }
                //BubbleSort(Singleton._instance.MestrosList);
                return(RedirectToAction(nameof(Index)));;
            }
            catch
            {
                return(View());
            }
        }
예제 #8
0
        private void cargarReparaciones(int idCliente)
        {
            using (MABEntities db = new MABEntities())
            {
                cliente = db.Clientes.Find(idCliente);

                reparaciones = (from rep in db.Reparaciones
                                where rep.Lavarropas.Cliente.Id == cliente.Id
                                select rep).ToList();
            }

            ucDGVTabla.dataSource(reparaciones);

            Text = "Seleccione una Reparacion del cliente " + cliente.nombre + " " + cliente.apellido;

            ucDGVTabla.Columns["Id"].Visible                  = false;
            ucDGVTabla.Columns["mesesGarantia"].Visible       = false;
            ucDGVTabla.Columns["reparacionRealizada"].Visible = false;
            ucDGVTabla.Columns["manoDeObra"].Visible          = false;
            ucDGVTabla.Columns["totalRepuestos"].Visible      = false;
            ucDGVTabla.Columns["LavarropasId"].Visible        = false;
            ucDGVTabla.Columns["Lavarropas"].Visible          = false;
            ucDGVTabla.Columns["Entregas"].Visible            = false;
            ucDGVTabla.Columns["Repuestos"].Visible           = false;
        }
예제 #9
0
 private void cargarCliente(int idCliente)
 {
     using (MABEntities db = new MABEntities())
     {
         cliente = db.Clientes.Find(idCliente);
     }
 }
예제 #10
0
        public async Task <IActionResult> AddCliente(Models.Clientes cliente)
        {
            cliente.CPFFormatado = cliente.CPF;
            cliente.CPF          = String.Join("", System.Text.RegularExpressions.Regex.Split(cliente.CPFFormatado, @"[^\d]"));
            var retorno = await Metodos.CallApiPostMetodo("Cliente", "SalvarCliente", cliente);

            return(RedirectToAction("Index"));
        }
예제 #11
0
        private void cargarCliente(int id)
        {
            using (MABEntities db = new MABEntities())
            {
                cliente = db.Clientes.Find(id);

                cclblNombreCliente.Text = cliente.nombre + " " + cliente.apellido;
            }
        }
예제 #12
0
        public ActionResult Create(Models.Clientes Clientes, int codigoCliente)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var db = new Models.SOFIAContext())
                    {
                        if (codigoCliente == 0)
                        {
                            db.Add(Clientes);
                            db.SaveChanges();
                        }
                        else
                        {
                            db.Update <Models.Clientes>(Clientes);
                            db.SaveChanges();
                        }
                    }
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    using (var db = new Models.SOFIAContext())
                    {
                        ViewData["Departamentos"] = db.Departamentos.ToList();
                        ViewData["Municipios"]    = db.Municipios.ToList();
                        ViewData["Pais"]          = db.Pais.ToList();
                        ViewData["Terminos"]      = db.TerminosPagos.ToList();
                    }
                    return(View(Clientes));
                    // return RedirectToActionPreserveMethod(nameof(Create),null ,Clientes);
                }

                //Models.Clientes c = new Models.Clientes();
                //var type = c.GetType();
                //PropertyInfo[] properties = type.GetProperties();
                //c.CodigoCliente = int.Parse(collection["CodigoCliente"]);

                //foreach (var key in collection.Keys) {
                //    var value = key.ToString();
                //    foreach (var p in properties) {
                //        if (p.Name == value) {
                //            p.SetValue(c,collection["value"]);
                //        }
                //    }

                //}
                // TODO: Add insert logic here
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
예제 #13
0
        public bool Insert(Models.Clientes cliente)
        {
            try
            {
                if (this.ValidCPFCNPJ(this.FormatCPF(cliente.cpf), "tbclientes", "cpfcnpj", this.FormatString(cliente.tipo)))
                {
                    var sql = string.Format("INSERT INTO tbclientes ( tipo, nomerazaosocial, sexo, logradouro, numero, complemento, bairro, telfixo, telcelular, email, codcidade, cep, cpfcnpj, rgie, dtnascimentofundacao, situacao, codcondicao, dtcadastro, dtultalteracao, apelidonomefantasia)" +
                                            "VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', {10}, '{11}', '{12}', '{13}', '{14}', '{15}', {16}, '{17}', '{18}', '{19}' )",
                                            this.FormatString(cliente.tipo),
                                            cliente.tipo == "F" ? this.FormatString(cliente.nomePessoa) : this.FormatString(cliente.razaoSocial),
                                            cliente.tipo == "F" ? this.FormatString(cliente.sexo) : "",
                                            this.FormatString(cliente.dsLogradouro),
                                            this.FormatString(cliente.numero),
                                            this.FormatString(cliente.complemento),
                                            this.FormatString(cliente.bairro),
                                            this.FormatPhone(cliente.telefoneFixo),
                                            this.FormatPhone(cliente.telefoneCelular),
                                            this.FormatString(cliente.email),
                                            cliente.Cidade.id,
                                            this.FormatCEP(cliente.cep),
                                            cliente.tipo == "F" ? this.FormatCPF(cliente.cpf) : this.FormatCNPJ(cliente.cnpj),
                                            cliente.tipo == "F" ? this.FormatRG(cliente.rg) : cliente.ie,
                                            cliente.tipo == "F" ? (cliente.dtNascimento != null ? cliente.dtNascimento.Value.ToString("yyyy-MM-dd") : "") : (cliente.dtNascimento != null ? cliente.dtFundacao.Value.ToString("yyyy-MM-dd") : ""),
                                            cliente.situacao.ToUpper().Trim(),
                                            cliente.CondicaoPagamento.id,
                                            DateTime.Now.ToString("yyyy-MM-dd"),
                                            DateTime.Now.ToString("yyyy-MM-dd"),
                                            cliente.tipo == "F" ? this.FormatString(cliente.apelidoPessoa) : this.FormatString(cliente.nomeFantasia)
                                            );
                    OpenConnection();
                    SqlQuery = new SqlCommand(sql, con);
                    int i = SqlQuery.ExecuteNonQuery();

                    if (i > 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception error)
            {
                throw new Exception(error.Message);
            }
            finally
            {
                CloseConnection();
            }
        }
예제 #14
0
        public bool Update(Models.Clientes cliente)
        {
            try
            {
                //if (this.ValidCPFCNPJ(this.FormatCPF(cliente.cpf), "tbclientes", "cpfcnpj", this.FormatString(cliente.tipo)))
                //{
                string sql = "UPDATE tbclientes SET tipo = '" +
                             this.FormatString(cliente.tipo) + "', " +
                             " nomerazaosocial = '" + (cliente.tipo == "F" ? this.FormatString(cliente.nomePessoa) : this.FormatString(cliente.razaoSocial)) + "', " +
                             " sexo = '" + (cliente.tipo == "F" ? this.FormatString(cliente.sexo) : "") + "', " +
                             " logradouro = '" + this.FormatString(cliente.dsLogradouro) + "', " +
                             " numero = '" + cliente.numero + "', " +
                             " complemento ='" + this.FormatString(cliente.complemento) + "', " +
                             " bairro = '" + this.FormatString(cliente.bairro) + "', " +
                             " telfixo = '" + this.FormatPhone(cliente.telefoneFixo) + "', " +
                             " telcelular = '" + this.FormatPhone(cliente.telefoneCelular) + "', " +
                             " email = '" + this.FormatString(cliente.email) + "', " +
                             " codcidade = " + cliente.Cidade.id + ", " +
                             " cep = '" + this.FormatCEP(cliente.cep) + "', " +
                             //" cpfcnpj = '" + (cliente.tipo == "F" ? this.FormatCPF(cliente.cpf) : this.FormatCNPJ(cliente.cnpj)) + "', " +
                             " rgie = '" + (cliente.tipo == "F" ? this.FormatRG(cliente.rg) : cliente.ie) + "', " +
                             " dtnascimentofundacao = '" + (cliente.tipo == "F" ? (cliente.dtNascimento != null ? cliente.dtNascimento.Value.ToString("yyyy-MM-dd") : "") : (cliente.dtFundacao != null ? cliente.dtFundacao.Value.ToString("yyyy-MM-dd") : "")) + "', " +
                             " situacao = '" + this.FormatString(cliente.situacao) + "', " +
                             " codcondicao = " + cliente.CondicaoPagamento.id + ", " +
                             " dtultalteracao = '" + (DateTime.Now.ToString("yyyy-MM-dd")) + "'," +
                             " apelidonomefantasia = '" + (cliente.tipo == "F" ? this.FormatString(cliente.apelidoPessoa) : this.FormatString(cliente.nomeFantasia)) + "'" +
                             " WHERE codcliente = " + cliente.codigo;
                OpenConnection();
                SqlQuery = new SqlCommand(sql, con);

                int i = SqlQuery.ExecuteNonQuery();

                if (i > 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                //}
                //return false;
            }
            catch (Exception error)
            {
                throw new Exception(error.Message);
            }
            finally
            {
                CloseConnection();
            }
        }
예제 #15
0
 public Boolean Agregar(Models.Clientes _clientes)
 {
     try
     {
         _clientesContext.Clientes.Add(_clientes);
         _clientesContext.SaveChanges();
         return(true);
     }
     catch (Exception error)
     {
         return(false);
     }
 }
예제 #16
0
 // GET: Clientes/Create
 public ActionResult Create(int Id)
 {
     Models.Clientes clientes = new Models.Clientes();
     using (var db = new Models.SOFIAContext())
     {
         ViewData["Departamentos"] = db.Departamentos.ToList();
         ViewData["Municipios"]    = db.Municipios.ToList();
         ViewData["Pais"]          = db.Pais.ToList();
         ViewData["Terminos"]      = db.TerminosPagos.ToList();
         clientes = db.Clientes.Find(Id);
     }
     return(View(clientes));
 }
예제 #17
0
 public frmEdición(Models.Clientes cliente) : this()
 {
     this.Text               = "Edición del Cliente";
     txtRazonSocial.Text     = cliente.RazonSocial;
     cbTipoDoc.SelectedIndex = cliente.IdTipoDocumento - 1;
     txtNroDocumento.Text    = cliente.NroDocumento.ToString();
     dtpFechaNac.Text        = cliente.FechaNacimiento.ToString();
     txtEmail.Text           = cliente.EMail;
     txtTelefono.Text        = cliente.Telefono;
     txtDireccion.Text       = cliente.Direccion;
     CargarDomicilio(cliente.IdDomicilio);
     ckEstado.Checked = cliente.Estado == 1;
 }
예제 #18
0
        private void cargarCliente(int idCliente)
        {
            using (MABEntities db = new MABEntities())
            {
                Cliente = db.Clientes.Find(idCliente);

                if (Cliente != null)
                {
                    Text = "Registrar Lavarropas";

                    cclblNombreCliente.Text = Cliente.nombre + " " + Cliente.apellido;
                }
            }
        }
예제 #19
0
        public Boolean Delete(Models.Clientes clientes)
        {
            try
            {
                _clientesContext.Clientes.Remove(clientes);
                _clientesContext.SaveChanges();
                return(true);
            }

            catch (Exception error)
            {
                return(false);
            }
        }
예제 #20
0
        private void cargarCliente(int idCliente)
        {
            using (MABEntities db = new MABEntities())
            {
                cliente = db.Clientes.Find(idCliente);

                cclblShowNumId.Text         = cliente.Id.ToString();
                cclblShowNombre.Text        = cliente.nombre;
                cclblShowApellido.Text      = cliente.apellido;
                cclblShowDireccion.Text     = cliente.direccion;
                cclblShowNumTelefonos.Text  = cliente.Telefonos.Count.ToString();
                cclblShowNumLavarropas.Text = cliente.Lavarropas.Count.ToString();
            }

            Text = "Detalle del Cliente " + cliente.nombre + " " + cliente.apellido;
        }
예제 #21
0
        public Boolean NuevoCliente(Models.Clientes data)
        {
            string Token    = HttpContext.Session.GetObjectFromJson <string>("SessionToken");
            string UserId   = HttpContext.Session.GetObjectFromJson <string>("SessionUserID");
            bool   clienteN = false;

            if (Token != null)
            {
                if (ClienteService.ValidateToken(Token, UserId))
                {
                    clienteN = ClienteService.Nuevo(data);
                }
            }

            return(clienteN);
        }
예제 #22
0
        private void refrescarTelefonos(int idCliente)
        {
            using (MABEntities db = new MABEntities())
            {
                cliente = db.Clientes.Find(idCliente);

                var data = (from telefonos in db.Telefonos
                            where telefonos.ClienteId == cliente.Id
                            select telefonos);

                ucDGVTabla.dataSource(data.ToList());
            }

            ucDGVTabla.Columns["ClienteId"].Visible = false;
            ucDGVTabla.Columns["Cliente"].Visible   = false;
        }
예제 #23
0
        public Inspeccion(Models.Clientes cliente, Models.Vehiculos vehiculo, int tipo)
        {
            InitializeComponent();
            BackColor         = Resources.Colors.Info;
            panel2.BackColor  = BackColor;
            button1.BackColor = BackColor;
            button1.ForeColor = Color.White;
            button2.BackColor = Resources.Colors.Secundary;
            button2.ForeColor = Color.White;
            _tipo             = tipo;
            _vehiculo         = vehiculo;
            _cliente          = cliente;

            textBox1.Text = _cliente.Nombre;
            textBox2.Text = $"{_vehiculo.NoPlaca}";
        }
예제 #24
0
        public Boolean Editar(Models.Clientes data)
        {
            bool   Exito  = false;
            string Token  = HttpContext.Session.GetObjectFromJson <string>("SessionToken");
            string UserId = HttpContext.Session.GetObjectFromJson <string>("SessionUserID");

            if (Token != null)
            {
                if (ClienteService.ValidateToken(Token, UserId))
                {
                    Exito = ClienteService.Actualizar(data);
                    return(Exito);
                }
            }

            return(Exito);
        }
예제 #25
0
        private void seleccionarCliente(object sender, EventArgs e)
        {
            if (ucDGVTabla.selectedRow() != null)
            {
                using (MABEntities db = new MABEntities())
                {
                    Models.Clientes cliente = db.Clientes.Find(Convert.ToInt32(ucDGVTabla.selectedRow().Cells["Id"].Value));

                    idCliente = cliente.Id;
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un Cliente primero", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #26
0
        public Boolean Nuevo(Models.Clientes data)
        {
            var _cliente = data;

            try
            {
                var cuenta = _clientesContext.Clientes.Where(x => x.Cuenta == data.Cuenta).ToList();

                _clientesContext.Clientes.Add(_cliente);
                _clientesContext.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public ActionResult Create(IFormCollection collection)
 {
     try
     {
         var NewCliente = new Models.Clientes
         {
             Nombre      = collection["Nombre"],
             Apellido    = collection["Apellido"],
             Telefono    = Convert.ToInt32(collection["Telefono"]),
             Descripcion = collection["Descripcion"],
         };
         Singleton.Instance.ClientesList.Add(NewCliente);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #28
0
        public bool Actualizar(Models.Clientes data)
        {
            try
            {
                Models.Clientes cliente = _clientesContext.Clientes.FirstOrDefault(x => x.Id == data.Id);

                _clientesContext.Clientes.Remove(cliente);

                _clientesContext.Clientes.Add(data);

                _clientesContext.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
예제 #29
0
        public string Put(Models.Clientes cli)
        {
            try
            {
                string query = String.Format(@"UPDATE `crmall_test`.`cliente`
                                                SET
                                                nome_cliente = '{1}',
                                                datanasc_cliente = '{2}' ,
                                                sexo_cliente = {3},
                                                cep_cliente = '{4}',
                                                endereco_cliente = '{5}',
                                                numero_cliente = '{6}',
                                                bairro_cliente = '{7}',
                                                estado_cliente = '{8}',
                                                cidade_cliente = '{9}'
                                                Where id_cliente = {0}",
                                             cli.id_cliente,
                                             cli.nome_cliente,
                                             cli.datanasc_cliente,
                                             cli.sexo_cliente,
                                             cli.cep_cliente,
                                             cli.endereco_cliente,
                                             cli.numero_cliente,
                                             cli.bairro_cliente,
                                             cli.estado_cliente,
                                             cli.cidade_cliente);

                DataTable table = new DataTable();
                using (var con = new MySqlConnection(ConfigurationManager.ConnectionStrings["crmall_test"].ConnectionString))
                    using (var cmd = new MySqlCommand(query, con))
                        using (var da = new MySqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }
                return("Alterado com Sucesso");
            }
            catch (Exception e)
            {
                return("Falha em Alterar : " + e.Message);
            }
        }
예제 #30
0
 public IHttpActionResult AgregarCliente(ClienteRequest model)
 {
     using (Models.CarCenterDB db = new Models.CarCenterDB())
     {
         var oCliente = new Models.Clientes();
         oCliente.PrimerNombre      = model.PrimerNombre;
         oCliente.SegundoNombre     = model.SegundoNombre;
         oCliente.PrimerApellido    = model.PrimerApellido;
         oCliente.SegundoApellido   = model.SegundoApellido;
         oCliente.TipoDocumento     = model.TipoDocumento;
         oCliente.NumeroDocumento   = model.NumeroDocumento;
         oCliente.NumeroCelular     = model.NumeroCelular;
         oCliente.Direccion         = model.Direccion;
         oCliente.CorreoElectronico = model.CorreoElectronico;
         oCliente.Presupuesto       = model.Presupuesto;
         db.Clientes.Add(oCliente);
         db.SaveChanges();
     }
     return(Ok("Cliente agregado satisfactoriamente"));
 }