示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            clientes clientes = db.clientes.Find(id);

            db.clientes.Remove(clientes);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
        private void btnEliminarCatalogoCliente_Click(object sender, EventArgs e)
        {
            clientes deli = new clientes();

            deli.eliminar(Convert.ToInt32(this.dgvCatalogoCliente.CurrentRow.Cells["pkIdcliente"].Value));

            cargardatos();
        }
        public void insert(Asistencia_Clientes cliente)
        {
            Boolean aumentarCeros = false;
            int     cantidadCeros = 0;
            String  ceros         = "";

            do
            {
                try
                {
                    bool bandera = false;
                    clientesCRUD = getClientes(cliente.cedula_cliente); // este me daba error

                    if (clientesCRUD != null)
                    {
                        bandera = true;
                    }

                    if (bandera == true)
                    {
                        if (aumentarCeros == true)
                        {
                            for (int i = 0; i <= cantidadCeros; i++)
                            {
                                ceros = ceros + 0;
                            }
                            Match  m   = Regex.Match(cliente.ID_Asistencia_Clientes, "(\\d+)");
                            string num = string.Empty;
                            if (m.Success)
                            {
                                num = m.Value;
                            }
                            cliente.ID_Asistencia_Clientes = "AC-" + ceros + num;
                        }
                        db.Asistencia_Clientes.InsertOnSubmit(cliente);
                        db.SubmitChanges();
                        MessageBox.Show("Asistencia guardada correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        aumentarCeros = false;
                    }
                    else
                    {
                        MessageBox.Show("La cedula del cliente no existe, por favor revise los datos ingresados", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("Violation of PRIMARY KEY") | ex.Message.Contains("DuplicateKeyException"))
                    {
                        aumentarCeros = true;
                        cantidadCeros++;
                    }
                    else
                    {
                        MessageBox.Show("Error Inesperado al guardar, Contacte con el administrador del Sistema :\n" + ex, "Error insert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            } while (aumentarCeros == true);
        }
        public ActionResult M_GetClientDiets(string c)
        {
            clientes cl      = db.clientes.Where(m => m.codigo == c).FirstOrDefault();
            Mobile   oMobile = new Mobile();
            int      today   = (int)CurrentDate.getNow().DayOfWeek;

            if (today == 0)
            {
                today = 7;
            }

            if (cl != null)
            {
                programa_clientes clientPrg = db.programa_clientes
                                              .Where(m => m.cliente_id == cl.id_alt && m.fecha_fin >= DateTimeOffset.Now)
                                              .OrderBy(m => m.fecha_fin)
                                              .FirstOrDefault();
                List <DailyDiet> clientDiets = db.clientes_dietas
                                               .Where(m => m.programa_clientes_id == clientPrg.id)
                                               .Include(m => m.dieta_diaria)
                                               .Select(m => m.dieta_diaria)
                                               .FirstOrDefault();

                if (clientDiets != null && clientDiets.Count > 0)
                {
                    Dictionary <string, object> oDict = new Dictionary <string, object>();
                    int dietCount = 0;
                    foreach (DailyDiet d in clientDiets)
                    {
                        if (d.dia == today)
                        {
                            Dictionary <string, object> dict = new Dictionary <string, object>();
                            dict.Add("day", d.dia);
                            dict.Add("food_type", d.tipo_comida);
                            dict.Add("text", d.texto);
                            dict.Add("option", d.opcion);

                            oDict.Add("E_" + dietCount.ToString(), dict);

                            dietCount++;
                        }
                    }
                    return(Json(
                               oMobile.GetDictForJSON(
                                   message: "",
                                   data: oDict,
                                   code: MobileResponse.Success),
                               JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(
                       oMobile.GetDictForJSON(
                           message: "Error en la solicitud",
                           data: null,
                           code: MobileResponse.Error),
                       JsonRequestBehavior.AllowGet));
        }
        public ActionResult Guardar(clientes model, int?departamentos)
        {
            ViewBag.inst = model.nombre;
            ViewBag.obj  = departamentos.ToString();

            return(View());
            //model.Guardar();
            //return Redirect("~/Clientes/Index");
        }
示例#6
0
    public int deleteClientes(int id_clientes)
    {
        clientes cliente = new clientes();

        cliente.Id_cliente = id_clientes;
        ClientesService dao = new ClientesServiceImpl();

        return((int)dao.remove(cliente));
    }
示例#7
0
 public ABMClientes(ModoForm modo, string usuario) : this()
 {
     Modo = modo;
     if (usuario != null)
     {
         ClienteActual = cliLog.GetOne(usuario);
         this.MapearDeDatos();
     }
 }
示例#8
0
        public ActionResult Editar(int?id)
        {
            using (var db = new ClienteEntities())
            {
                clientes cl = db.clientes.Find(id);

                return(View(cl));
            }
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            clientes clientes = await db.clientes.FindAsync(id);

            db.clientes.Remove(clientes);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        // Eliminar Cliente

        public ActionResult Delete(string id)
        {
            clientes regCli = bd.clientes.Where(c => c.IdCliente == id).First();

            bd.clientes.Remove(regCli);
            bd.SaveChanges();

            return(RedirectToAction("Index"));
        }
示例#11
0
 // POST: api/Cliente
 public string Post([FromBody] clientes cli)
 {
     using (brugaelEntities bd = new brugaelEntities())
     {
         bd.clientes.Add(cli);
         bd.SaveChanges();
         return("Salvo com sucesso");
     }
 }
示例#12
0
 public EditarCliente(string nitCliente)
 {
     InitializeComponent();
     clinit                 = nitCliente;
     cli                    = bd.clientes.Find(clinit);
     tbCICliente.Text       = cli.nitCliente;
     tbNombreCliente.Text   = cli.nombreCliente;
     tbApellidoCliente.Text = cli.apellidoCliente;
 }
示例#13
0
 public void CambiarEstado(clientes cliente, string estado)
 {
     if (cliente != null)
     {
         cliente.estado = estado;
         context.Entry(cliente).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
        public async Task <ActionResult> M_GetNewKey(string c)
        {
            Mobile   oMobile = new Mobile();
            clientes cl      = db.clientes.Where(m => m.codigo == c).FirstOrDefault();

            if (cl != null)
            {
                Random r   = new Random();
                int    key = r.Next(1000, 9999);
                cl.password        = key;
                db.Entry(cl).State = EntityState.Modified;

                int s = await db.SaveChangesAsync();

                if (s > 0)
                {
                    RestClient client = new RestClient();
                    client.BaseUrl       = new Uri("https://api.mailgun.net/v3");
                    client.Authenticator =
                        new HttpBasicAuthenticator("api",
                                                   "key-44f7133c62e338cd2e8b2286c0285eac");
                    RestRequest request = new RestRequest();
                    request.AddParameter("domain",
                                         "sgc.personaltraining.com.pe", ParameterType.UrlSegment);
                    request.Resource = "{domain}/messages";
                    request.AddParameter("from", "Personal Training Perú <*****@*****.**>");
                    request.AddParameter("to", cl.email);
                    request.AddParameter("to", cl.email_empresa);
                    request.AddParameter("subject", "Personal Training Perú App - Nueva Contraseña App");

                    string body = "Estimado cliente(a), su nueva clave para la aplicación es: " + key.ToString();

                    request.AddParameter("text", body);
                    request.Method = Method.POST;
                    IRestResponse response = client.Execute(request);

                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Dictionary <string, object> oDict = new Dictionary <string, object>();
                        oDict.Add("key", key);
                        return(Json(
                                   oMobile.GetDictForJSON(
                                       message: "Clave cambiada correctamente.",
                                       data: oDict,
                                       code: MobileResponse.Success),
                                   JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json(
                       oMobile.GetDictForJSON(
                           message: "Error de validación de cliente.",
                           data: null,
                           code: MobileResponse.Success),
                       JsonRequestBehavior.AllowGet));
        }
 private void reloadForm()
 {
     this.Refresh();
     this.Controls.Clear();
     this.InitializeComponent();
     this.Cliente  = new clientes();
     this.Empleado = new empleadoModel();
     obtenerCitas();
     obtenerServicios();
 }
示例#16
0
 public ActionResult modificaCliente(clientes objC)
 {
     if (!ModelState.IsValid)
     {
         ViewBag.pais = new SelectList(bd.GetPaises(), "Idpais", "NombrePais", objC.idpais);
         return(View(objC));
     }
     bd.Put(objC);
     return(RedirectToAction("listadoClientes"));
 }
示例#17
0
 public ActionResult Edit([Bind(Include = "id_cliente,nombre,apellidos,direccion,telefono,email,moroso")] clientes clientes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientes));
 }
示例#18
0
 public ActionResult Eliminar(int id)
 {
     using (var db = new GestionDeAlmacenContext())
     {
         clientes cl4 = db.clientes.Find(id);
         db.clientes.Remove(cl4);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
示例#19
0
 public ActionResult Edit([Bind(Include = "idclientes,nome,dtNascimento,cpf,valorGasto")] clientes clientes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientes));
 }
示例#20
0
        public ActionResult agregaCliente(clientes objC)

        {
            if (!ModelState.IsValid)
            {
                return(View(objC));
            }
            bd.Post(objC);
            return(RedirectToAction("listadoClientes"));
        }
示例#21
0
 public ActionResult Edit([Bind(Include = "cedulaPK,nombre,apellido1,apellido2,telefono,provincia,canton,distrito,correo,direccionDetallada")] clientes clientes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientes));
 }
 public ActionResult Edit([Bind(Include = "id,razonsocial,rfc")] clientes clientes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientes));
 }
示例#23
0
 public ActionResult Edit([Bind(Include = "id_cliente,tipodoc_cliente,doc_cliente,nom_cliente,apell_cliente,contacto_cliente,genero_cliente")] clientes clientes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientes));
 }
示例#24
0
 public ActionResult Edit([Bind(Include = "idCliente,nombres,edad,telefono")] clientes clientes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clientes));
 }
示例#25
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (RentcarEntities db = new RentcarEntities())
     {
         if (txt_fullname.Text.Trim() == "" || txt_cedula.Text.Trim() == "" || txt_numero_cr.Text.Trim() == "" || string.IsNullOrEmpty(cmb_tipo_persona.Text) | txt_limite_credito.Text.Trim() == "" || !radioButton1.Checked && !radioButton2.Checked)
         {
             MessageBox.Show("Todos los campos son obligatorios.");
         }
         else if (!IsValidDrCedula(txt_cedula.Text.Trim()))
         {
             MessageBox.Show("La cedula no es valida.");
         }
         else
         {
             if (this.id == null)
             {
                 clientes oClientes = new clientes();
                 oClientes.full_name      = txt_fullname.Text.Trim();
                 oClientes.cedula         = txt_cedula.Text.Trim();
                 oClientes.numero_cr      = txt_numero_cr.Text.Trim();
                 oClientes.limite_credito = txt_limite_credito.Text.Trim();
                 oClientes.tipo           = cmb_tipo_persona.SelectedItem.ToString();
                 if (radioButton1.Checked)
                 {
                     oClientes.estado = true;
                 }
                 else if (radioButton2.Checked)
                 {
                     oClientes.estado = false;
                 }
                 db.clientes.Add(oClientes);
             }
             else
             {
                 oClientes                = db.clientes.Find(this.id);
                 oClientes.full_name      = txt_fullname.Text.Trim();
                 oClientes.cedula         = txt_cedula.Text.Trim();
                 oClientes.numero_cr      = txt_numero_cr.Text.Trim();
                 oClientes.limite_credito = txt_limite_credito.Text.Trim();
                 oClientes.tipo           = cmb_tipo_persona.SelectedItem.ToString();
                 if (radioButton1.Checked)
                 {
                     oClientes.estado = true;
                 }
                 else if (radioButton2.Checked)
                 {
                     oClientes.estado = false;
                 }
                 db.Entry(oClientes).State = System.Data.Entity.EntityState.Modified;
             }
             db.SaveChanges();
             this.Close();
         }
     }
 }
        public ActionResult M_LogInClient(string c, int k)
        {
            Mobile oMobile = new Mobile();

            clientes cl          = db.clientes.Where(m => m.codigo == c).Include(m => m.nutricionistas.usuarios).FirstOrDefault();
            int      daysInMonth = DateTime.DaysInMonth(CurrentDate.getNow().Year, CurrentDate.getNow().Month);

            DateTime firstDay = new DateTime(CurrentDate.getNow().Year, CurrentDate.getNow().Month, 1);
            DateTime lastDay  = new DateTime(CurrentDate.getNow().Year, CurrentDate.getNow().Month, daysInMonth);

            if (cl != null && k == cl.password)
            {
                DateTime          today     = CurrentDate.getNow();
                programa_clientes clientPrg = db.programa_clientes.Where(m => m.cliente_id == cl.id_alt && m.fecha_fin >= today).Include(m => m.programa).OrderBy(m => m.fecha_fin).FirstOrDefault();
                venta_usuarios    clientSls = db.venta_usuarios.Where(m => m.cliente_id == cl.id_alt && m.fecha_fin >= today).OrderBy(m => m.fecha_fin).FirstOrDefault();

                if (clientPrg == null || clientSls == null)
                {
                    return(Json(
                               oMobile.GetDictForJSON(
                                   message: "Cliente no cuenta con programa asignado o boleta vigente en el sistema.",
                                   data: null,
                                   code: MobileResponse.Success),
                               JsonRequestBehavior.AllowGet));
                }

                citas clientAppointments = db.citas.Where(m => m.cliente_id == cl.id_alt && m.fecha > today).OrderBy(m => m.fecha).FirstOrDefault();

                Dictionary <string, object> oDict = new Dictionary <string, object>();
                oDict.Add(key: "name", value: cl.nombres);
                oDict.Add(key: "last_name", value: cl.apellidos);
                oDict.Add(key: "code", value: cl.id_alt);
                oDict.Add(key: "img", value: Convert.ToBase64String(cl.foto));
                oDict.Add(key: "curr_program", value: clientPrg.programa.nombre);
                oDict.Add(key: "curr_nutritionist", value: cl.nutricionistas.usuarios.nombres ?? null);
                oDict.Add(key: "curr_ticket", value: clientSls.numero_boleta);
                oDict.Add(key: "upcoming_nut_appointment_date", value: clientAppointments != null ? clientAppointments.fecha.ToShortDateString() : null);
                oDict.Add(key: "upcoming_membership_renewal_date", value: clientSls != null ? clientSls.fecha_fin.ToShortDateString() : null);


                return(Json(
                           oMobile.GetDictForJSON(
                               message: "Inicio de sesión correcto.",
                               data: oDict,
                               code: MobileResponse.Success),
                           JsonRequestBehavior.AllowGet));
            }

            return(Json(
                       oMobile.GetDictForJSON(
                           message: "Error de inicio de sesión.",
                           data: null,
                           code: MobileResponse.Error),
                       JsonRequestBehavior.AllowGet));
        }
示例#27
0
        public ActionResult Create([Bind(Include = "idCliente,nombres,edad,telefono")] clientes clientes)
        {
            if (ModelState.IsValid)
            {
                db.clientes.Add(clientes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clientes));
        }
示例#28
0
        public ActionResult Create([Bind(Include = "id_cliente,tipodoc_cliente,doc_cliente,nom_cliente,apell_cliente,contacto_cliente,genero_cliente")] clientes clientes)
        {
            if (ModelState.IsValid)
            {
                db.clientes.Add(clientes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clientes));
        }
示例#29
0
        public async Task <IActionResult> Create([Bind("Id,UserName,Email,PhoneNumber,CPF,ReleaseDate,Convenio,Coment")] clientes clientes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clientes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientes));
        }
示例#30
0
        public ActionResult Create([Bind(Include = "id_cliente,nombre,apellidos,direccion,telefono,email,moroso")] clientes clientes)
        {
            if (ModelState.IsValid)
            {
                db.clientes.Add(clientes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clientes));
        }