コード例 #1
0
        public ActionResult Index(Empleado empleado)
        {
            Respuesta respuesta = new Respuesta();

            if (true)
            {
                respuesta.success = true;
                respuesta.message = "OK";
            }
            return Json(respuesta);
        }
コード例 #2
0
        public ActionResult Index(Acceso login)
        {
            RespAcceso respuesta = new RespAcceso();
            try {
                SqlDataReader reader = null;
                SqlConnection myConnection = new SqlConnection();
                try
                {
                    myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
                    myConnection.Open();
                    SqlCommand command = new SqlCommand("select * from RESTAURANT a, EMPLEADO b where b.EMPL_COD = " + login.num_empleado + " and a.REST_ID = " + login.rest_id + " and b.EMPL_STAT ='ALTA'", myConnection);
                    reader = command.ExecuteReader();
                    Empleado emp = new Empleado();
                    Restaurant rest = new Restaurant();
                    while (reader.Read())
                    {

                        rest.rest_des = reader["rest_des"].ToString();
                        rest.rest_id = Convert.ToInt32(reader["rest_id"].ToString());
                        rest.succ_id = Convert.ToInt32(reader["succ_id"].ToString());
                        emp.empl_apm = reader["empl_apm"].ToString();
                        emp.empl_app = reader["empl_app"].ToString();
                        emp.empl_cod = Convert.ToInt32(reader["empl_cod"].ToString());
                        emp.empl_nom = reader["empl_nom"].ToString();
                        emp.empl_stat = reader["empl_stat"].ToString();
                        emp.empl_tipo = reader["empl_tipo"].ToString();
                        emp.succ_id = Convert.ToInt32(reader["succ_id"].ToString());

                    }//end while
                    respuesta.restaurant = rest;
                    respuesta.empleado = emp;
                }
                catch (SqlException sqlExc)
                {
                    respuesta.success = false;
                    respuesta.message = "ERROR " + sqlExc.Message;
                }
                finally
                {
                    myConnection.Close();
                }
                //fin try-catch SQL
            }catch(Exception ex){
                respuesta.success = false;
                respuesta.message = "ERROR " + ex.Message;
            }//Fin Try-catch General
            respuesta.success = true;
            respuesta.message = "OK";
            return Json(respuesta);
        }
コード例 #3
0
        public ActionResult Index(AliveRequest aliv)
        {
            Alive res = new Alive();
            SqlDataReader reader = null;
            SqlConnection myConnection = new SqlConnection();
            try
            {

                myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
                myConnection.Open();
                SqlCommand command = new SqlCommand("select * from ff_cat_usuario", myConnection);
                reader = command.ExecuteReader();
                List<Empleado> listaEmpl = new List<Empleado>();
                while (reader.Read())
                {
                    Empleado emp = new Empleado();
                    emp.empl_nom = reader["usr_nombre"].ToString();
                    listaEmpl.Add(emp);
                }//end while
                res.body = listaEmpl;
            }
            catch (SqlException e)
            {
                res.success = false;
                res.message = "ERROR DB " + e.Message;
                return Json(res);
            }
            finally
            {
                myConnection.Close();
            }

            if (aliv.request)
            {
                res.success = true;
                res.message = "OK";
            }
            else
            {
                res.success = false;
                res.message = "ERROR 404";
            }
            //return Json(res);
            return Json(res);
        }
コード例 #4
0
        public ActionResult appEntrar(Acceso login)
        {
            log.Info("Solicitando appEntrar");
            RespAcceso respuesta = new RespAcceso();
            try
            {
                SqlDataReader reader = null;
                SqlConnection myConnection = new SqlConnection();
                Empleado emp = null;
                RestDetalle rest = null;
                log.Debug("Restaurante " +login.rest_id);
                log.Debug(" |Validando contraseña " + login.password); // " contra contraseña de restaurant " + ConfigurationManager.AppSettings[login.rest_id].ToString());
                log.Debug("1= " + ConfigurationManager.AppSettings["1"].ToString());
                log.Debug("?= " + ConfigurationManager.AppSettings[""+login.rest_id].ToString());
                string pass = null;
                try
                {
                    pass = ConfigurationManager.AppSettings["" + login.rest_id].ToString();
                }catch(Exception exrr){
                    log.Error("ERROR VALIDANDO CONTRASEÑA EN "+ exrr.Message);
                }
                if(pass== null){
                    log.Debug("Configuracion de contraseña, incorrecta");
                    respuesta.success = false;
                    respuesta.message = "CONFIGURACION DE CONTRASEÑA, INCORRECTA";
                    respuesta.restaurant = rest;
                    respuesta.empleado = emp;
                }
                else if ( pass == login.password)
                {
                    log.Debug("Contraseña Valida");
                    try
                    {
                        myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
                        myConnection.Open();
                        //SqlCommand command = new SqlCommand("select * from RESTAURANT a, EMPLEADO b where b.EMPL_COD = " + login.num_empleado + " and a.REST_ID = " + login.rest_id + " and b.EMPL_STAT ='ALTA'", myConnection);
                        SqlCommand command = new SqlCommand("select (select SUCC_DES from SUCURSAL where SUCC_ID = a.SUCC_ID) as SUCC_DES, * from 	RESTAURANT a, ff_cat_usuario b where b.usr_numempleado = " + login.num_empleado + " and a.REST_ID = " + login.rest_id, myConnection);
                        reader = command.ExecuteReader();

                        while (reader.Read())
                        {
                            emp = new Empleado();
                            rest = new RestDetalle();
                            rest.rest_des = reader["rest_des"].ToString();
                            rest.rest_id = Convert.ToInt32(reader["rest_id"].ToString());
                            rest.succ_id = Convert.ToInt32(reader["succ_id"].ToString());
                            rest.succ_des = reader["succ_des"].ToString();
                            emp.empl_apm = "";
                            emp.empl_app = "";
                            emp.empl_cod = Convert.ToInt32(reader["usr_numempleado"].ToString());
                            emp.empl_nom = reader["usr_nombre"].ToString();
                            emp.empl_stat = "ALTA";
                            emp.empl_tipo = "MESERO";
                            emp.succ_id = Convert.ToInt32(reader["succ_id"].ToString());
                        }//end while
                        if (emp != null && rest != null)
                        {
                            respuesta.success = true;
                            respuesta.message = "OK";
                            respuesta.restaurant = rest;
                            respuesta.empleado = emp;
                        }
                        else
                        {
                            respuesta.success = false;
                            respuesta.message = "CONTRASEÑA INVÁLIDA";
                            respuesta.restaurant = rest;
                            respuesta.empleado = emp;
                        }

                    }
                    catch (SqlException sqlExc)
                    {
                        log.Error("Error en SQLException appEntrar en " + sqlExc.Message);
                        respuesta.success = false;
                        respuesta.message = "ERROR " + sqlExc.Message;
                        return Json(respuesta);
                    }
                    finally
                    {
                        myConnection.Close();
                    }
                }
                else
                {
                    log.Debug("Contraseña incorrecta");
                    respuesta.success = false;
                    respuesta.message = "CONTRASEÑA INVÁLIDA";
                    respuesta.restaurant = rest;
                    respuesta.empleado = emp;
                }
                //fin try-catch SQL
            }
            catch (Exception ex)
            {
                log.Error("Error solicitando appEntrar en "+ ex.Message);
                respuesta.success = false;
                respuesta.message = "ERROR " + ex.Message;
                return Json(respuesta);
            }//Fin Try-catch General
            return Json(respuesta);
        }
コード例 #5
0
 public ActionResult getEmpleados(ReqEmpleados emp)
 {
     RespEmpleado empleados = new RespEmpleado();
     SqlDataReader reader = null;
     SqlConnection myConnection = new SqlConnection();
     try
     {
         myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
         myConnection.Open();
         SqlCommand command = new SqlCommand("select * from ff_cat_usuario where usr_succ_id =@SUCC", myConnection);
         command.Parameters.AddWithValue("@SUCC", emp.succ_id);
         reader = command.ExecuteReader();
         List<Empleado> listaEmpleado = new List<Empleado>();
         while (reader.Read())
         {
             Empleado empleado = new Empleado();
             empleado.empl_cod = Convert.ToInt32(reader["usr_id"].ToString());
             empleado.empl_nom = reader["usr_numempleado"].ToString();
             empleado.empl_tipo = reader["usr_nombre"].ToString();
             listaEmpleado.Add(empleado);
         }
         empleados.listaEmpleados = listaEmpleado;
     }
     catch (Exception ex)
     {
         empleados.success = false;
         empleados.message = "ERROR " + ex.Message;
         return Json(empleados);
     }
     finally
     {
         myConnection.Close();
     }
     empleados.success = true;
     empleados.message = "OK";
     return Json(empleados);
 }