public ActionResult getOrdenesActivas(Acceso acceso)
 {
     log.Info("Solicitando getOrdenesActivas");
     RespOrdenesActivas ordenesActivas = new RespOrdenesActivas();
     try
     {
         SqlDataReader reader = null;
         SqlConnection myConnection = new SqlConnection();
         List<OrdenActiva> listaOrdenes = new List<OrdenActiva>();
         try
         {
             myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
             myConnection.Open();
             //SqlCommand command = new SqlCommand("select a.ORDN_ID,a.ORDN_NPER, a.ORDN_IMPTOT, a.ORDN_STAT, a.MESA_ID, 		(select d.ordn_hmov from ORDEN_CTRL d where d.ORDN_ID = a.ORDN_ID) as ORDN_HMOV,		(select c.MESA_cve from MESA c where c.MESA_ID = a.MESA_ID) as MESA_CVE		  from orden a where a.ORDN_MESE= "+acceso.num_empleado+" and a.ORDN_STAT= 'INIC' or a.ORDN_STAT = 'CAMM'", myConnection);
             SqlCommand command = new SqlCommand("select a.ORDN_ID,a.ORDN_NPER, a.ORDN_IMPTOT, a.ORDN_STAT, a.MESA_ID, 		(select d.ordn_hmov from ORDEN_CTRL d where d.ORDN_ID = a.ORDN_ID) as ORDN_HMOV,		(select c.MESA_cve from MESA c where c.MESA_ID = a.MESA_ID) as MESA_CVE		  from orden a where a.ORDN_MESE= " + acceso.num_empleado + " and (select c.rest_id from MESA c where c.MESA_ID =a.MESA_ID) = "+acceso.rest_id + " and a.ORDN_STAT= 'INIC' or a.ORDN_STAT = 'CAMM'", myConnection);
             reader = command.ExecuteReader();
             while (reader.Read())
             {
                 OrdenActiva orden = new OrdenActiva();
                 orden.mesa_cve = reader["mesa_cve"].ToString();
                 orden.mesa_id = Convert.ToInt32(reader["mesa_id"].ToString());
                 orden.ordn_hmov = Convert.ToInt32(reader["ordn_hmov"].ToString());
                 orden.ordn_id = Convert.ToInt32(reader["ordn_id"].ToString());
                 orden.ordn_imptot = Convert.ToDecimal(reader["ordn_imptot"].ToString());
                 orden.ordn_nper = Convert.ToInt32(reader["ordn_nper"].ToString());
                 orden.ordn_stat = reader["ordn_stat"].ToString();
                 listaOrdenes.Add(orden);
             }
             ordenesActivas.total_ordenes = listaOrdenes.Count;
             ordenesActivas.ordenesActivas = listaOrdenes;
         }
         catch (SqlException sqlex)
         {
             log.Error("Error en SQLException getOrdenesActivas en " + sqlex.Message);
             ordenesActivas.success = false;
             ordenesActivas.message = "ERROR " + sqlex;
             return Json(ordenesActivas);
         }
         finally
         {
             myConnection.Close();
         }
     }
     catch (Exception exc)
     {
         log.Error("Error  getOrdenesActivas en " + exc.Message);
         ordenesActivas.success = false;
         ordenesActivas.message = "ERROR " + exc.Message;
         return Json(ordenesActivas);
     }
     ordenesActivas.success = true;
     ordenesActivas.message = "OK";
     return Json(ordenesActivas);
 }
 public ActionResult Index(Acceso acceso)
 {
     RespOrdenesActivas ordenesActivas = new RespOrdenesActivas();
     try
     {
         SqlDataReader reader = null;
         SqlConnection myConnection = new SqlConnection();
         List<OrdenActiva> listaOrdenes = new List<OrdenActiva>();
         try
         {
             myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString;
             myConnection.Open();
             SqlCommand command = new SqlCommand("SELECT " +
                                                 "A.ORDN_ID, " +
                                                 "A.ORDN_NPER, " +
                                                 "A.ORDN_IMPTOT," +
                                                 "A.ORDN_STAT, " +
                                                 "A.MESA_ID, " +
                                                 "B.ORDN_HMOV, " +
                                                 "C.MESA_CVE "+
                                                 "   FROM "+
                                                 "ORDEN A, "+
                                                 "ORDEN_CTRL B, "+
                                                 "MESA C "+
                                                 "   WHERE "	+
                                                 "A.ORDN_STAT = 'INIC' "+
                                                 " AND	A.ORDN_MESE = " +acceso.num_empleado +
                                                 " AND	B.ORDN_ID = A.ORDN_ID"+
                                                 " AND	C.MESA_ID = A.MESA_ID;", myConnection);
             reader = command.ExecuteReader();
             while(reader.Read()){
                 OrdenActiva orden = new OrdenActiva();
                 orden.mesa_cve = reader["mesa_cve"].ToString();
                 orden.mesa_id = Convert.ToInt32(reader["mesa_id"].ToString());
                 orden.ordn_hmov = Convert.ToInt32(reader["ordn_hmov"].ToString());
                 orden.ordn_id = Convert.ToInt32(reader["ordn_id"].ToString());
                 orden.ordn_imptot = Convert.ToDecimal(reader["ordn_imptot"].ToString());
                 orden.ordn_nper = Convert.ToInt32(reader["ordn_nper"].ToString());
                 orden.ordn_stat = reader["ordn_stat"].ToString();
                 listaOrdenes.Add(orden);
             }
             ordenesActivas.total_ordenes = listaOrdenes.Count;
             ordenesActivas.ordenesActivas = listaOrdenes;
         }
         catch(SqlException sqlex){
             ordenesActivas.success = false;
             ordenesActivas.message = "ERROR " + sqlex;
             return Json(ordenesActivas);
         }
         finally{
             myConnection.Close();
         }
     }
     catch(Exception exc)
     {
         ordenesActivas.success = false;
         ordenesActivas.message = "ERROR " + exc.Message;
         return Json(ordenesActivas);
     }
     ordenesActivas.success = true;
     ordenesActivas.message = "OK";
     return Json(ordenesActivas);
 }