public ActionResult bajaEmpleado(ReqEmpleado emp) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE EMPLEADO SET EMPL_STAT = 'BAJA' WHERE EMPL_COD = @COD", myConnection); command.Parameters.AddWithValue("@COD", emp.empl_cod); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO HUBO ACTUALIZACION"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult deleteImpresora(RefImpresora refImpresora) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("DELETE FROM IMPRESORA WHERE IMPR_ID = @IMPR", myConnection); command.Parameters.AddWithValue("@IMPR", refImpresora.impr_id); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE ELIMINO IMPRESORA"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult Alive() { Respuesta resp = new Respuesta(); resp.success = true; resp.message = "OK"; return Json(resp); }
public ActionResult Index(Empleado empleado) { Respuesta respuesta = new Respuesta(); if (true) { respuesta.success = true; respuesta.message = "OK"; } return Json(respuesta); }
public ActionResult newSucursal(Sucursal newSucursal) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO SUCURSAL (SUCC_ID, SUCC_DES) VALUES (@ID, @DES) ", myConnection); command.Parameters.AddWithValue("@ID", newSucursal.succ_id); command.Parameters.AddWithValue("@DES", newSucursal.succ_des); command.ExecuteNonQuery(); command.Parameters.Clear(); } catch (SqlException ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } resp.success = true; resp.message = "OK"; return Json(resp); }
public ActionResult updateSucursal(Sucursal sucursal) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE SUCURSAL SET SUCC_DES = @DES WHERE SUCC_ID = @ID ", myConnection); command.Parameters.AddWithValue("@ID", sucursal.succ_id); command.Parameters.AddWithValue("@DES", sucursal.succ_des); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO HUBO ACTUALIZACION"; } command.Parameters.Clear(); } catch (SqlException ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult updateUbicacion(Ubicacion ubic) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE UBICACION SET UBIC_DES =@DESC WHERE UBIC_CONSEC = @CONSEC AND REST_ID =@REST", myConnection); command.Parameters.AddWithValue("@REST", ubic.rest_id); command.Parameters.AddWithValue("@CONSEC", ubic.ubic_consec); command.Parameters.AddWithValue("@DESC", ubic.ubic_des); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE COMPLETO LA ACTUALIZACION"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult updateMesa(Mesa mesa) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE MESA SET MESA_CVE = @MESACVE, MESA_DES =@MESADES, MESA_STAT =@MESASTAT, REST_ID = @RESTID, UBIC_CONSEC= @UBIC WHERE MESA_ID = @MESAID", myConnection); command.Parameters.AddWithValue("@MESACVE", mesa.mesa_cve); command.Parameters.AddWithValue("@MESADES", mesa.mesa_des); command.Parameters.AddWithValue("@RESTID", mesa.rest_id); command.Parameters.AddWithValue("@UBIC", mesa.ubic_consec); command.Parameters.AddWithValue("@MESAID", mesa.mesa_id); command.Parameters.AddWithValue("@MESASTAT", mesa.mesa_stat); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE CREO LA UBICACION"; return Json(resp); } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult deleteMesa(IdentifMesa mesa) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("DELETE FROM MESA WHERE MESA_ID = @MESA", myConnection); command.Parameters.AddWithValue("@MESA", mesa.mesa_id); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE CREO LA UBICACION"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult isValidOrden(ValidaOrdenMesero ordenmesero) { Respuesta resp = new Respuesta(); SqlDataReader reader = null; SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand(" SELECT COUNT(*) as contar FROM ORDEN where ORDN_ID = " +ordenmesero.ordn_id+" and ORDN_MESE = "+ordenmesero.ordn_mese, myConnection); reader = command.ExecuteReader(); int iContador = 0; while (reader.Read()) { iContador = Convert.ToInt32(reader["contar"].ToString()); } if (0 < iContador) { resp.message = "OK"; resp.success = true; } else { resp.message = "ORDEN NO PERTENECE A MESERO"; resp.success = false; } } catch(Exception ex){ resp.message ="Error: "+ ex.Message; resp.success = false; } return Json(resp); }
public ActionResult deleteSucursal(ReqSucursal sucursal) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("DELETE FROM SUCURSAL WHERE SUCC_ID = @ID ", myConnection); command.Parameters.AddWithValue("@ID", sucursal.succ_id); command.ExecuteNonQuery(); command.Parameters.Clear(); } catch (SqlException ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } resp.success = true; resp.message = "OK"; return Json(resp); }
public ActionResult traspasoCuentas(TraspasoOrrdenesMese trasp) { log.Info("Solicitando traspasoCuentas de " + trasp.mese_orig + " a " + trasp.mese_nuevo); Respuesta resp = new Respuesta(); SqlCommand command = null; SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); command = new SqlCommand("UPDATE ORDEN SET ORDN_MESE = @NVO WHERE ORDN_MESE = @ORIG", myConnection); command.Parameters.AddWithValue("@NVO", trasp.mese_nuevo ); command.Parameters.AddWithValue("@ORIG", trasp.mese_orig); if (0 > command.ExecuteNonQuery()) { resp.success = false; resp.message += " ERROR -650"; return Json(resp); } else { command = new SqlCommand("UPDATE ORDEN_CTRL SET EMPL_COD = @NVO , ORDN_STAT = 'CAMM' WHERE ORDN_STAT = 'INIC' AND EMPL_COD =@ORIG", myConnection); command.Parameters.AddWithValue("@NVO", trasp.mese_nuevo); command.Parameters.AddWithValue("@ORIG", trasp.mese_orig); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } } }catch(Exception ex){ log.Error("Error en traspasoCuentas en "+ex.Message); resp.success = false; resp.message = "ERROR " + ex.Message; }finally{ myConnection.Close(); } return Json(resp); }
public ActionResult finOrden(RefOrden orden) { log.Info("Solicitando finOrden de orden " + orden.ordn_id); string sNombreRest = null; Respuesta resp = new Respuesta(); SqlDataReader reader = null; SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("select REST_DES from RESTAURANT where REST_ID =(select rest_id from MESA where MESA_id = (select MESA_ID from ORDEN where ORDN_ID= " +orden.ordn_id+"))", myConnection); log.Debug("Obteniendo Informacion de Base-Restaurante"); reader = command.ExecuteReader(); while(reader.Read()){ sNombreRest = reader["REST_DES"].ToString(); sNombreRest = sNombreRest.Replace(" ", ""); log.Debug("Base de Orden =" + sNombreRest); } command = new SqlCommand("UPDATE ORDEN SET ORDN_STAT = 'FINC' WHERE ORDN_ID = @ORDEN", myConnection); command.Parameters.AddWithValue("@ORDEN", orden.ordn_id); if (0 < command.ExecuteNonQuery()) { command = new SqlCommand(" UPDATE ORDEN_CTRL SET ORDN_STAT = 'FINC' WHERE ORDN_ID = @ORDEN", myConnection); command.Parameters.AddWithValue("@ORDEN", orden.ordn_id); if (0 < command.ExecuteNonQuery()) { command = new SqlCommand(" UPDATE MESA SET MESA_STAT = 'ALTA' WHERE MESA_ID=@MESAID", myConnection); command.Parameters.AddWithValue("@MESAID", orden.mesa_id); if (0 < command.ExecuteNonQuery()) { command = new SqlCommand(" select * from orden_articulo where ordn_id = " + orden.ordn_id, myConnection); reader = command.ExecuteReader(); while (reader.Read()) {//INSERTA EN LA DB CORRESPONDIENTE LA VENTA if (insertaVenta(reader, sNombreRest)) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "ERROR INSERTANDO EN BASE DE RESTAURANT"; return Json(resp); } } } else { resp.success = false; resp.message = "NO SE COMPLETO FINALIZAR ORDEN-3 " + orden.ordn_id; return Json(resp); } } else { resp.success = false; resp.message = "NO SE COMPLETO FINALIZAR ORDEN-2 " + orden.ordn_id; return Json(resp); } } else { resp.success = false; resp.message = "NO SE COMPLETO FINALIZAR ORDEN " + orden.ordn_id; return Json(resp); } }catch(Exception ex){ log.Error("Error en finOrden en " + ex.Message); resp.success = false; resp.message ="ERROR "+ex.Message; } finally { myConnection.Close(); } try { printOrden(orden); } catch(Exception ex) { log.Error("Error printOrden en " + ex.Message); log.Error(ex.StackTrace); } return Json(resp); }
public ActionResult newRestaurant(ReqNewRestaurant req) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO RESTAURANT (REST_DES, SUCC_ID) VALUES (@RESTDES, @SUC) ", myConnection); command.Parameters.AddWithValue("@RESTDES", req.rest_des); command.Parameters.AddWithValue("@SUC", req.succ_id); command.ExecuteNonQuery(); command.Parameters.Clear(); } catch (SqlException ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } resp.success = true; resp.message = "OK"; return Json(resp); }
public ActionResult newMesa(NewMesa mesa) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO MESA (MESA_CVE, MESA_DES, MESA_STAT, REST_ID, UBIC_CONSEC) VALUES (@CVE, @DES, 'ALTA', @REST, @UBIC);", myConnection); command.Parameters.AddWithValue("@CVE", mesa.mesa_cve); command.Parameters.AddWithValue("@DES", mesa.mesa_des); command.Parameters.AddWithValue("@REST", mesa.rest_id); command.Parameters.AddWithValue("@UBIC", mesa.ubic_consec); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE CREO LA MESA"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult newImpresora(NewImpresora impr) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO IMPRESORA (IMPR_CONF, IMPR_DES, IMPR_STAT, REST_ID, TIPP_ID, UBIC_CONSEC) VALUES (@CONF , @DES , 'ALTA' , @REST , @TIPP , @CONSEC)", myConnection); command.Parameters.AddWithValue("@CONF", impr.impr_conf); command.Parameters.AddWithValue("@DES", impr.impr_des); command.Parameters.AddWithValue("@REST", impr.rest_id); command.Parameters.AddWithValue("@TIPP", impr.tipp_id); command.Parameters.AddWithValue("@CONSEC", impr.ubic_consec); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE CREO MESA"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult deleteUbicacion(ReferenceUbicacion ubicacion) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("DELETE FROM UBICACION WHERE REST_ID = @REST AND UBIC_CONSEC = @CONSEC", myConnection); command.Parameters.AddWithValue("@REST", ubicacion.rest_id); command.Parameters.AddWithValue("@CONSEC", ubicacion.ubic_consec); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE ELIMINO LA UBICACION CORRECTAMENTE"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult newEmpleado(NuevoEmpleado emp) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO EMPLEADO (EMPL_NOM, EMPL_APP, EMPL_APM, EMPL_COD, EMPL_STAT, EMPL_TIPO, SUCC_ID) "+ "VALUES (@NOM, @PAT, @MAT, @COD, 'ALTA', @TIPO, @SUCC )", myConnection); command.Parameters.AddWithValue("@NOM", emp.empl_nom); command.Parameters.AddWithValue("@PAT", emp.empl_app); command.Parameters.AddWithValue("@MAT", emp.empl_apm); command.Parameters.AddWithValue("@COD", emp.empl_cod); command.Parameters.AddWithValue("@TIPO", emp.empl_tipo); command.Parameters.AddWithValue("@SUCC", emp.succ_id); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO OCURRIO INSERT"; } command.Parameters.Clear(); } catch (SqlException ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult consolidarOrdenes(ConsolidaOrdenes listaOrdenesCons) { log.Info("Solicitando consolidarOrdenes"); Respuesta resp = new Respuesta(); SqlDataReader reader = null; SqlCommand command = null; SqlConnection myConnection = new SqlConnection(); decimal sumTotal =0; try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); DateTime fecha = DateTime.Now; int iFecha = Convert.ToInt32("" + fecha.Year + "" + fecha.Month + "" + fecha.Day); int iHora = Convert.ToInt32(fecha.Hour + "" + fecha.Minute); resp.message += "-3"; foreach (OrdenRefer numOrdenaConsolidar in listaOrdenesCons.ordenes) { int mesaactua=0; command= new SqlCommand("select ordn_imptot, mesa_id from ORDEN where ORDN_ID= @IDORD", myConnection); command.Parameters.AddWithValue("@IDORD", numOrdenaConsolidar.ordn_id); resp.message += "-5"; reader = command.ExecuteReader(); while (reader.Read()) { sumTotal += Convert.ToDecimal(reader["ordn_imptot"].ToString()); mesaactua = Convert.ToInt32(reader["mesa_id"].ToString()); } command = new SqlCommand("UPDATE ORDEN SET ORDN_STAT ='CONS' WHERE ORDN_ID =@IDORDD", myConnection); command.Parameters.AddWithValue("@IDORDD", numOrdenaConsolidar.ordn_id); if (0 > command.ExecuteNonQuery()){ resp.success = false; resp.message+=" ERROR -633"; return Json(resp); } command = new SqlCommand("UPDATE MESA SET MESA_STAT ='ALTA' WHERE MESA_ID ="+mesaactua, myConnection); if (0 > command.ExecuteNonQuery()){ resp.success = false; resp.message+=" ERROR -665"; return Json(resp); } //"" command = new SqlCommand("update ORDENART_MODIF set ORDN_ID = @IDNEW where ORDN_ID =@IDORDD ", myConnection); command.Parameters.AddWithValue("@IDNEW", listaOrdenesCons.ordn_id); command.Parameters.AddWithValue("@IDORDD", numOrdenaConsolidar.ordn_id); if (0 > command.ExecuteNonQuery()) { resp.success = false; resp.message += " ERROR -670"; return Json(resp); } command = new SqlCommand("UPDATE ORDEN_ARTICULO SET ORDN_ID = @IDNEW WHERE ORDN_ID =@IDORDD ", myConnection); command.Parameters.AddWithValue("@IDNEW", listaOrdenesCons.ordn_id); command.Parameters.AddWithValue("@IDORDD", numOrdenaConsolidar.ordn_id); if (0 > command.ExecuteNonQuery()) { resp.success = false; resp.message += " ERROR -679"; return Json(resp); } command = new SqlCommand("UPDATE COMANDA SET ORDN_ID = @IDNEW WHERE ORDN_ID = @IDORDD ", myConnection); command.Parameters.AddWithValue("@IDNEW", listaOrdenesCons.ordn_id); command.Parameters.AddWithValue("@IDORDD", numOrdenaConsolidar.ordn_id); if (0 > command.ExecuteNonQuery()) { resp.success = false; resp.message += " ERROR -687"; return Json(resp); } } command= new SqlCommand("select ordn_imptot from ORDEN where ORDN_ID= @IDORD", myConnection); command.Parameters.AddWithValue("@IDORD", listaOrdenesCons.ordn_id); resp.message += "-6"; reader = command.ExecuteReader(); while (reader.Read()) { sumTotal+= Convert.ToDecimal(reader["ordn_imptot"].ToString()); } command = new SqlCommand("UPDATE ORDEN SET ordn_imptot =@PRECTOT WHERE ORDN_ID =@IDO", myConnection); command.Parameters.AddWithValue("@IDO", listaOrdenesCons.ordn_id); command.Parameters.AddWithValue("@PRECTOT", sumTotal); if (0 > command.ExecuteNonQuery()) { resp.success = false; resp.message += " ERROR -650"; return Json(resp); } else { resp.success = true; resp.message += " OK"; } } catch(Exception ext){ log.Error("Error en consolidarOrdenes en " + ext.Message); resp.success = false; resp.message = "ERROR " + ext.Message; return Json(resp); } finally{ myConnection.Close(); } return Json(resp); }
public ActionResult newUbicacion(NewUbicacion ubic) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO UBICACION(REST_ID, UBIC_DES) VALUES(@REST, @DESC);", myConnection); command.Parameters.AddWithValue("@REST", ubic.rest_id); command.Parameters.AddWithValue("@DESC", ubic.ubic_des); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE CREO LA UBICACION"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; } return Json(resp); }
public ActionResult updateEmpleado(NuevoEmpleado emp) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE EMPLEADO SET EMPL_APM = @APM, EMPL_APP =@APP, EMPL_NOM =@NOM, EMPL_TIPO =@TIPO WHERE EMPL_COD = @COD", myConnection); command.Parameters.AddWithValue("@APM", emp.empl_apm); command.Parameters.AddWithValue("@COD", emp.empl_cod); command.Parameters.AddWithValue("@NOM", emp.empl_nom); command.Parameters.AddWithValue("@TIPO", emp.empl_tipo); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO HUBO ACTUALIZACION"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult updateImpresora(Impresora impresora) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("UPDATE IMPRESORA SET IMPR_CONF =@CONF, IMPR_DES =@DES, IMPR_STAT=@STATUT, REST_ID=@REST, TIPP_ID=@TIPP, UBIC_CONSEC= @UBIC WHERE IMPR_ID = @IMPRID", myConnection); command.Parameters.AddWithValue("@CONF", impresora.impr_conf); command.Parameters.AddWithValue("@DES", impresora.impr_des); command.Parameters.AddWithValue("@IMPRID", impresora.impr_id); command.Parameters.AddWithValue("@REST", impresora.rest_id); command.Parameters.AddWithValue("@TIPP", impresora.tipp_id); command.Parameters.AddWithValue("@UBIC", impresora.ubic_consec); command.Parameters.AddWithValue("@STATUT", impresora.impr_stat); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message = "OK"; } else { resp.success = false; resp.message = "NO SE ACTUALIZO IMPRESORA"; } } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult newComanda( newComanda newcomand) { log.Info("Solicitando newComanda de orden "+newcomand.ordn_id); SqlDataReader reader = null; Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); decimal imptot = 0; int idComanda=0; try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("INSERT INTO COMANDA (ORDN_ID, COMA_STAT) VALUES (@ORDN, 'INIC') SELECT CAST(SCOPE_IDENTITY() AS INT)", myConnection); command.Parameters.AddWithValue("@ORDN", newcomand.ordn_id); resp.message += "-1"; idComanda = (int)command.ExecuteScalar(); if (0 < idComanda) { resp.message += "-2"; DateTime fecha = DateTime.Now; int iFecha = Convert.ToInt32("" + fecha.Year + "" + fecha.Month + "" + fecha.Day); int iHora = Convert.ToInt32(fecha.Hour + "" + fecha.Minute); resp.message += "-3"; command = null; resp.message += "-4"; command = new SqlCommand("INSERT INTO COMANDA_CTRL (COMA_ID, COMA_STAT, COMA_FMOV, COMA_HMOV, COMA_OBSV) VALUES (@IDCOM, 'INIC', @FECH, @HORA, @OBSV)", myConnection); resp.message += "-5"; command.Parameters.AddWithValue("@IDCOM", idComanda); command.Parameters.AddWithValue("@FECH", iFecha); command.Parameters.AddWithValue("@HORA", iHora); command.Parameters.AddWithValue("@OBSV", newcomand.coma_obsv); resp.message += "-6"; if (0 < command.ExecuteNonQuery()) { resp.message += "-7"; foreach (OrdenArticulo artOrd in newcomand.ordenarticulo) { resp.message += "-8"; command = new SqlCommand("INSERT INTO ORDEN_ARTICULO (ORDN_ID, COMA_ID, ART_EAN, ORDN_CANT, ORDN_IMPUNI, ORDN_IMPART, ORDN_OBSV) VALUES (@ORDN_ID,@COMA_ID,@ART_EAN,@ORDN_CANT,@ORDN_IMPUNI,@ORDN_IMPART,@OBSV)", myConnection); command.Parameters.AddWithValue("@ORDN_ID", newcomand.ordn_id); command.Parameters.AddWithValue("@COMA_ID", idComanda); command.Parameters.AddWithValue("@ART_EAN", artOrd.art_ean); command.Parameters.AddWithValue("@ORDN_CANT", artOrd.ordn_cant); command.Parameters.AddWithValue("@ORDN_IMPUNI", artOrd.ordn_impuni); command.Parameters.AddWithValue("@ORDN_IMPART", artOrd.ordn_impart); command.Parameters.AddWithValue("@OBSV", artOrd.ordn_obsv); imptot += artOrd.ordn_impart; if (0 < command.ExecuteNonQuery()) { resp.message += "-9"; if (artOrd.hasModif == true) { foreach (Modificadoresart modiff in artOrd.modificadores) { //resp.message += "-10"; command = new SqlCommand("INSERT INTO ORDENART_MODIF (ORDN_ID, COMA_ID, ART_EAN, AGRU_ID, AGRU_CONSEC) VALUES (@ORDN_ID,@COMA_ID,@ART_EAN,@AGRU_ID,@AGRU_CONSEC)", myConnection); command.Parameters.AddWithValue("@ORDN_ID", newcomand.ordn_id); command.Parameters.AddWithValue("@COMA_ID", idComanda); command.Parameters.AddWithValue("@ART_EAN", artOrd.art_ean); command.Parameters.AddWithValue("@AGRU_ID", modiff.agru_id); command.Parameters.AddWithValue("@AGRU_CONSEC", modiff.agru_consec); if (0 < command.ExecuteNonQuery()) { resp.message += "-11|||"; resp.success = true; resp.message += "532: OK"; } }//fin foreach } else { resp.success = true; resp.message += "539: OK"; } } else { resp.success = false; resp.message += "MESA NO ACTUALIZADA"; } }//end foreach command = new SqlCommand("select ordn_imptot from ORDEN where ORDN_ID= @IDORD", myConnection); command.Parameters.AddWithValue("@IDORD", newcomand.ordn_id); reader = command.ExecuteReader(); while (reader.Read()) { imptot += Convert.ToDecimal(reader["ordn_imptot"].ToString()); } command = new SqlCommand("UPDATE ORDEN SET ordn_imptot =@PRECTOT WHERE ORDN_ID =@IDO", myConnection); command.Parameters.AddWithValue("@IDO", newcomand.ordn_id); command.Parameters.AddWithValue("@PRECTOT", imptot); if (0 < command.ExecuteNonQuery()) { resp.success = true; resp.message += "567: OK"; } try { resp.message += " | PRINT"; printComanda(newcomand); resp.message += " | PRINTGOOD"; }catch(Exception ext){ resp.success = false; resp.message += "Error PRINT="+ext.Message; } } else { resp.success = false; resp.message += "ORDEN_CTRL NO ACTUALIZADA"; } } else { resp.success = false; resp.message += "NO SE CREO NUEVA ORDEN"; } command.Parameters.Clear(); } catch (Exception ex) { log.Error("Error en newComanda en " + ex.Message); resp.success = false; resp.message += "ERROR a. " + ex.Message; return Json(resp); } finally { myConnection.Close(); } return Json(resp); }
public ActionResult deleteRestaurante(ReqDeleteRestaurant req) { Respuesta resp = new Respuesta(); SqlConnection myConnection = new SqlConnection(); try { myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["BaseComercial"].ConnectionString; myConnection.Open(); SqlCommand command = new SqlCommand("DELETE FROM RESTAURANT WHERE REST_ID = @RESTID", myConnection); command.Parameters.AddWithValue("@RESTID", req.rest_id); command.ExecuteNonQuery(); } catch (Exception ex) { resp.success = false; resp.message = "ERROR " + ex.Message; return Json(resp); } finally { myConnection.Close(); } resp.success = true; resp.message = "OK"; return Json(resp); }