// GET: Clientes/Edit/5
 public ActionResult Editar(int?id)
 {
     if (cls_session.checkSession())
     {
         Sys_Usuarios activeuser = Session["activeUser"] as Sys_Usuarios;
         //HEADER
         //ACTIVE PAGES
         ViewData["Menu"]      = "CRM";
         ViewData["Page"]      = "Clientes";
         ViewBag.menunameid    = "";
         ViewBag.submenunameid = "";
         //AUTH
         List <string> s = new List <string>(activeuser.Departamentos.Split(new string[] { "," }, StringSplitOptions.None));
         ViewBag.lstDepartments = JsonConvert.SerializeObject(s);
         List <string> r = new List <string>(activeuser.Roles.Split(new string[] { "," }, StringSplitOptions.None));
         ViewBag.lstRoles = JsonConvert.SerializeObject(r);
         //NOTIFICATIONS
         List <Sys_Notificaciones> lstAlerts = (from a in db.Sys_Notificaciones where (a.ID_usuario == activeuser.ID_usuario && a.Activo == true) select a).OrderByDescending(x => x.Fecha).Take(4).ToList();
         ViewBag.notifications = lstAlerts;
         //DATA VIEW
         ViewBag.activeuser = activeuser;
         //END HEADER
         Tb_Clientes tb_Clientes = db.Tb_Clientes.Find(id);
         ViewBag.ID_empresa = new SelectList(db.Sys_Empresas, "ID_empresa", "Nombre", tb_Clientes.ID_empresa);
         return(View(tb_Clientes));
     }
     else
     {
         return(RedirectToAction("Login", "Home", new { access = false }));
     }
 }
        public ActionResult DeleteConfirmedPotenciales(int id)
        {
            Tb_Clientes tb_Clientes = db.Tb_Clientes.Find(id);

            db.Tb_Clientes.Remove(tb_Clientes);
            db.SaveChanges();
            return(RedirectToAction("Potenciales"));
        }
Example #3
0
        private void CargamosDatos()
        {
            DataTable dt = Tb_Clientes.listadoClientes();

            if (dt != null)
            {
                dgv_Clientes.ItemsSource = dt.DefaultView;
            }
        }
Example #4
0
 private void creamosPedido()
 {
     pedido               = new Pedido();
     pedido.Codigo        = lbId.Content == null ? 0 : Convert.ToInt32(lbId.Content);
     pedido.NumPedido     = Convert.ToInt32(txtCodPedido.Texto);
     pedido.CodCliente    = Tb_Clientes.dameCodigoCliente(cbCliente.Texto);
     pedido.Fecha         = Convert.ToDateTime(txtFecha.Fecha);
     pedido.Estado        = cbEstado.ItemSeleccionado();
     pedido.Observaciones = txtComentario.Texto;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                Tb_Clientes tb_Clientes = db.Tb_Clientes.Find(id);
                db.Tb_Clientes.Remove(tb_Clientes);
                db.SaveChanges();
            }
            catch {
            }

            return(RedirectToAction("Activos"));
        }
        // GET: Clientes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tb_Clientes tb_Clientes = db.Tb_Clientes.Find(id);

            if (tb_Clientes == null)
            {
                return(HttpNotFound());
            }
            return(View(tb_Clientes));
        }
 public ActionResult Editar([Bind(Include = "ID_cliente,Nombre,Apellido,DUI,Telefono,Correo,Direccion,Contrasena,Empresa,Lead,ID_empresa")] Tb_Clientes tb_Clientes)
 {
     tb_Clientes.ID_empresa = 1;
     if (tb_Clientes.Empresa == null)
     {
         tb_Clientes.Empresa = "";
     }
     tb_Clientes.Contrasena = "";
     if (ModelState.IsValid)
     {
         db.Entry(tb_Clientes).State = EntityState.Modified;
         db.SaveChanges();
     }
     return(RedirectToAction("Activos", "Clientes"));
 }
Example #8
0
        public void CargarDatos()
        {
            dt = Tb_Clientes.listadoClientes();
            //cbCliente.AddItems("Selecciona cliente");
            foreach (DataRow miRow in dt.Rows)
            {
                cbCliente.AddItems(miRow.ItemArray[1].ToString());
            }


            //cbEstado.AddItems("Selecciona Estado");
            cbEstado.AddItems("En espera");
            cbEstado.AddItems("En proceso");
            cbEstado.AddItems("Listo");
        }
Example #9
0
        private void TrabajoConLaTabla(object sender, RoutedEventArgs e)
        {
            dt     = Tb_Pedidos.listadoPedidos();
            pedido = new Pedido();
            Int32 filaActual = -1;

            if (lbId.Content == null)
            {
                lbId.Content = 0;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i].ItemArray[0].ToString() == lbId.Content.ToString())
                {
                    filaActual = i;
                    break;
                }
            }

            switch (((Button)sender).Name)
            {
            case "btnNextReg":
                filaActual = (filaActual < dt.Rows.Count - 1)? filaActual + 1 : filaActual;
                break;

            case "btnPrevReg":
                filaActual = (filaActual == 0) ? filaActual : filaActual - 1;
                break;

            case "btnFirstReg":
                filaActual = 0;
                break;

            case "btnLastReg":
                filaActual = dt.Rows.Count;
                break;
            }

            lbId.Content       = dt.Rows[filaActual].ItemArray[0].ToString();
            txtCodPedido.Texto = dt.Rows[filaActual].ItemArray[1].ToString();
            cbCliente.SeleccionarItem(Tb_Clientes.damePoscionCliente(Convert.ToInt32(dt.Rows[filaActual].ItemArray[2])) + 1);
            txtFecha.Fecha = Convert.ToDateTime(dt.Rows[filaActual].ItemArray[3]);
            cbEstado.SeleccionarItem(Convert.ToInt16(dt.Rows[filaActual].ItemArray[4]));
            txtComentario.Texto = dt.Rows[filaActual].ItemArray[5].ToString();
            cargarLineasPedido();
        }
Example #10
0
        private void TrabajoBotones(object sender, RoutedEventArgs e)
        {
            if (ComprobamosDatos())
            {
                switch (((Button)sender).Name)
                {
                case "btn_Add":
                    creamosCliente();
                    if (Tb_Clientes.addCliente(cliente))
                    {
                        new MensajeBox("CLIENTE INTRODUCIDO CON EXITO");
                    }
                    break;

                case "btn_Update":
                    creamosCliente();
                    if (Tb_Clientes.updateCliente(cliente))
                    {
                        new MensajeBox("CLIENTE ACTUALIZADO CON EXITO");
                    }
                    break;

                case "btn_Del":
                    MessageBoxResult respuesta = new MensajeBox("ESTA OPERACION NO TIENE MARCHA ATRÁS.", BOTONES.ACEPTARCANCEL).Respuesta;
                    if (respuesta == MessageBoxResult.OK)
                    {
                        creamosCliente();
                        if (Tb_Clientes.delCliente(cliente))
                        {
                            new MensajeBox("CLIENTE ELIMINADO CON EXITO");
                        }
                        LimpiarCampos();
                    }

                    break;
                }
                CargamosDatos();
            }
        }
 public ActionResult Nuevo([Bind(Include = "ID_cliente,Nombre,Apellido,DUI,Telefono,Correo,Direccion,Contrasena,Empresa,Lead,ID_empresa")] Tb_Clientes tb_Clientes)
 {
     tb_Clientes.ID_empresa = 1;
     tb_Clientes.Contrasena = "";
     tb_Clientes.Lead       = false;
     if (tb_Clientes.Direccion == null)
     {
         tb_Clientes.Direccion = "";
     }
     if (tb_Clientes.Empresa == null)
     {
         tb_Clientes.Empresa = "";
     }
     if (ModelState.IsValid)
     {
         db.Tb_Clientes.Add(tb_Clientes);
         db.SaveChanges();
         return(RedirectToAction("Activos", "Clientes"));
     }
     else
     {
         return(RedirectToAction("Activos", "Clientes"));
     }
 }
Example #12
0
        public ActionResult Crear(int idcliente, string nombrecliente, string empresacliente, string telefonocliente, string fecha, List <detallescot> detalles)
        {
            try
            {
                Tb_Cotizaciones nuevaCotizacion = new Tb_Cotizaciones();
                nuevaCotizacion.ID_empresa    = 1;
                nuevaCotizacion.Telefono      = telefonocliente;
                nuevaCotizacion.No_Cotizacion = "";
                nuevaCotizacion.Empresa       = empresacliente;
                nuevaCotizacion.Fecha         = Convert.ToDateTime(fecha);
                if (idcliente == 0)
                {
                    //creamos cliente
                    Tb_Clientes nuevoCliente = new Tb_Clientes();
                    nuevoCliente.Nombre     = nombrecliente;
                    nuevoCliente.Apellido   = "";
                    nuevoCliente.DUI        = "";
                    nuevoCliente.Telefono   = telefonocliente;
                    nuevoCliente.Correo     = "";
                    nuevoCliente.Direccion  = "";
                    nuevoCliente.Contrasena = "";
                    nuevoCliente.Empresa    = empresacliente;
                    nuevoCliente.Lead       = true;
                    nuevoCliente.ID_empresa = 1;

                    db.Tb_Clientes.Add(nuevoCliente);
                    db.SaveChanges();

                    nuevaCotizacion.ID_cliente = nuevoCliente.ID_cliente;
                }
                else
                {
                    nuevaCotizacion.ID_cliente = idcliente;
                }

                db.Tb_Cotizaciones.Add(nuevaCotizacion);
                db.SaveChanges();

                //Detalles
                if (detalles.Count > 0)
                {
                    foreach (var item in detalles)
                    {
                        Tb_Cotizacion_detalle nuevoDetalleCot = new Tb_Cotizacion_detalle();
                        nuevoDetalleCot.Descripcion   = item.descripcion;
                        nuevoDetalleCot.Costo         = Convert.ToDecimal(item.costo);
                        nuevoDetalleCot.Horas         = Convert.ToInt32(item.horas);
                        nuevoDetalleCot.ID_servicio   = 0;
                        nuevoDetalleCot.ID_cotizacion = nuevaCotizacion.ID_cotizacion;
                        db.Tb_Cotizacion_detalle.Add(nuevoDetalleCot);
                    }
                    db.SaveChanges();
                }


                var result = "SUCCESS";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var resulterror = ex.Message;
                return(Json(resulterror, JsonRequestBehavior.AllowGet));
            }
        }