public List<sucursal> getSucursal(int nrocli, string token) { try { if (!ControladorToken.comprobarToken(token)) { throw new Exception(); } List<sucursal> s = new List<sucursal>(); using (GestionEntities bd = new GestionEntities()) { if (bd.sucursal.Where(a => a.nrocli == nrocli).Count() == 0) { s.Add(new sucursal()); return s; } else return bd.sucursal.Where(a => a.nrocli == nrocli).ToList(); } } catch (Exception) { return null; } }
internal int cantClientes(int nrocli) { using (GestionEntities bd = new GestionEntities()) { return(bd.cliente.Where(a => a.nrocli == nrocli).Count()); } }
//usado mostrar en la cabecera public RequestHTTP getClientePresupuesto(int nrocli) { var req = new RequestHTTP(); try { using (GestionEntities bd = new GestionEntities()) req.objeto = bd.Database.SqlQuery <ClientePesupuesto>("SELECT dbo.cliente.nrocli, " + " dbo.cliente.razsoc, dbo.cliente.direcc, dbo.cliente.locali AS localicod, " + " dbo.localidades.nombre AS nombreLocali, depto.nombre AS deptoNombre, depto.id," + " depto.provincia_id, dbo.provincias.nombre AS nombreProv, dbo.pais.pais, " + " dbo.cliente.cuit, dbo.cliente.respon AS Iva, dbo.iva.descripcion AS descriIva, " + " dbo.cliente.tipodoc, dbo.cliente.condicion, dbo.cliente.lista, dbo.vende.codven," + " dbo.vende.nombre AS nombreVende, dbo.cliente.respon, dbo.cliente.telef1, " + " dbo.cliente.bonif, dbo.cliente.bonif1, dbo.cliente.bonif2, dbo.cliente.bonif3," + " dbo.cliente.bonif4, dbo.cliente.convenio, dbo.cliente.nopercib, dbo.cliente.expreso," + " dbo.cliente.cond_vta" + " FROM dbo.cliente" + " LEFT OUTER JOIN dbo.localidades ON dbo.localidades.id = dbo.cliente.locali " + " LEFT OUTER JOIN dbo.departamentos AS depto ON depto.id = dbo.localidades.departamento_id" + " LEFT OUTER JOIN dbo.provincias ON dbo.provincias.id = depto.provincia_id " + " LEFT OUTER JOIN dbo.pais ON dbo.provincias.pais_id = dbo.pais.id " + " LEFT OUTER JOIN dbo.iva ON dbo.iva.id = dbo.cliente.respon " + " LEFT OUTER JOIN dbo.vende ON dbo.vende.codven = dbo.cliente.codven where nrocli = " + nrocli).Single(); return(req); } catch (Exception e) { return(req.falla(e)); } }
internal string getConcepto(int condicion) { using (GestionEntities bd = new GestionEntities()) { return(bd.Database.SqlQuery <string>("select descripcion from condpago where codigo = " + condicion).Single()); } }
internal List <passwd> getUsuarios() { using (GestionEntities bd = new GestionEntities()) { return(bd.passwd.ToList()); } }
internal RequestHTTP getVendedoresFiltro(string param) { var req = new RequestHTTP(); try { int nrocli; using (GestionEntities bd = new GestionEntities()) { if (int.TryParse(param, out nrocli)) { nrocli = Convert.ToInt32(param); req.objeto = bd.Database.SqlQuery <vendedor>("select codven, nombre from vende where codven = " + param + " and nombre like '%" + param + "%'").ToList(); } else { req.objeto = bd.Database.SqlQuery <vendedor>("select codven, nombre from vende where nombre like '%" + param + "%'").ToList(); } return(req); } } catch (Exception e) { return(req.falla(e)); } }
internal RequestHTTP getComprasProvee(int empresa, string desde, string hasta, int concepto, bool cotizacion) { var req = new RequestHTTP(); try { string ccCotiza = "and tipodoc <> 'CT'"; using (GestionEntities bd = new GestionEntities()) { if (!cotizacion) { ccCotiza = ""; } req.objeto = bd.Database.SqlQuery <comprasProveedores>( "select max(nropro) nropro, max(razsoc) razsoc, sum(neto + neto1 + exento) total " + "from ivacom " + "where fecha >= '" + desde + "' and fecha <= '" + hasta + "' and concepto = " + concepto + " " + ccCotiza + " " + "group by nropro " + "order by total desc").ToList(); } return(req); }catch (Exception e) { return(req.falla(e)); } }
//----------------------------------------------------------CLIENTES public RequestHTTP getClientes(int codven, bool veTodos, int offset) { var req = new RequestHTTP(); try { List <ClienteBuscador> clientes; using (GestionEntities bd = new GestionEntities()) { if (veTodos) { req.objeto = bd.Database.SqlQuery <ClienteBuscador>( "select nrocli, razsoc, cuit, fantasia, direcc, telef1, telef2, codven " + "from cliente " + "order by nrocli " + "offset " + offset + " " + "rows fetch next 20 row only").ToList(); } else { req.objeto = bd.Database.SqlQuery <ClienteBuscador>( "select nrocli, razsoc, cuit, fantasia, direcc, telef1, telef2, codven " + "from cliente " + "where codven = " + codven + " " + "order by nrocli " + "offset " + offset + " rows fetch next 20 row only").ToList(); } } return(req); }catch (Exception e) { return(req.falla(e)); } }
public RequestHTTP getCliente(int paran) { cliente cli; var req = new RequestHTTP(); try { using (GestionEntities bd = new GestionEntities()) { if (bd.cliente.Where(a => a.nrocli == paran).Count() == 1) { cli = bd.cliente.Single(a => a.nrocli == paran); } else { cli = new cliente(); cli.nrocli = 0; } req.objeto = cli; return(req); } } catch (Exception e) { return(req.falla(e)); } }
internal List <UltimoPrecio> getUltimosPrecios(int nrocli, string codpro, string token) { using (GestionEntities bd = new GestionEntities()) { return(bd.Database.SqlQuery <UltimoPrecio>("select c.fecha, c.tipodoc, c.letra, c.punto, c.numero, c.neto, detmovim.bonif, detmovim.bonif1, detmovim.bonito from ivaven c left join detmovim on detmovim.ivavenid = c.id where c.nrocli = " + nrocli + " and codpro like '" + codpro + "' order by fecha desc").ToList()); } }
public FWmasDatos getMasDatos(int nrocli, string token, int empresa) { { FWmasDatos resul = new FWmasDatos(); /*try if (!ControladorToken.comprobarToken(token)) throw new Exception(); */ using (GestionEntities bd = new GestionEntities()) { resul.convertirFWmasDatos(bd.FWmasDatos(nrocli).Single()); resul.codMoneda = bd.configen.Single(a => a.empresa == empresa).nmonedacl; resul.cotizMoneda = bd.monedas.Single(a => a.codigo == resul.codMoneda).ncotiza; return resul; } /* } catch (Exception) { return null; }*/ } }
public decimal getCotizacion(string codigo) { using (GestionEntities bd = new GestionEntities()) { return bd.monedas.Single(a => a.codigo == codigo).ncotiza; } }
//Pedido-Presupuestodsdsad //usado en el modal public List <clienteModal> getClientesPresupuesto() { if (clienteModal == null) { using (GestionEntities bd = new GestionEntities()) clienteModal = bd.clienteModal.ToList(); } return(clienteModal); }
private PedidoCab armaCabecera(JObject jCabecera, decimal bonifcli) { decimal nroped; double vence; int provin, jPunto, jEmpresa, jSucursal, jViaid, jLocali, jNrocli, jTipoDocId, jCondPago, id, jUsuarioId; string sucursal, via, jProvin, localidad, codpos, monfac, usuario, jNotaVenta, presup = ""; jPunto = (int)jCabecera["punto"]; jEmpresa = (int)jCabecera["empresa"]; jSucursal = (int)jCabecera["sucursal"]; jViaid = (int)jCabecera["viaid"]; jProvin = (string)jCabecera["provin"]; usuario = jCabecera["usuario"].ToString(); jNrocli = (int)jCabecera["nrocli"]; jTipoDocId = 1007;//(int)jCabecera["tipodocid"]; jCondPago = (int)jCabecera["condicion"]; jUsuarioId = (int)jCabecera["usuarioid"]; jNotaVenta = jCabecera["notavta"].ToString(); monfac = jCabecera["monfac"].ToString(); using (GestionEntities bd = new GestionEntities()) {//recibe parametros y busca el nombre o id jLocali = bd.cliente.Single(a => a.nrocli == jNrocli).locali; nroped = bd.factura.Single(a => a.PUNTO == jPunto && a.EmpresaId == jEmpresa).PEDIDO; provin = bd.provincias.Single(a => a.nombre == jProvin).id; sucursal = bd.sucursal.Single(a => a.id == jSucursal).sucursal1; via = bd.via.Single(a => a.id == jViaid).via1; localidad = bd.localidades.Single(a => a.id == jLocali).nombre; codpos = bd.cliente.Single(a => a.nrocli == jNrocli).codpos; vence = Convert.ToDouble(bd.condpago.Single(a => a.codigo == jCondPago).dias); if (bd.PedidoCab.Count() > 0) { id = bd.PedidoCab.ToList().Last().id + 1; } else { id = 1; } } DateTime parafecha = Convert.ToDateTime(jCabecera["parafecha"].ToString()); //transformacion de DateTime 2 a Datetime porque no reconoce DateTime pfe = Convert.ToDateTime(parafecha.ToString("dd/MM/yyyy")); var cabeceraPedido = new PedidoCab((int)jCabecera["empresa"], jTipoDocId, (int)jCabecera["punto"], "PD", "X", Convert.ToDateTime(jCabecera["fechai"]), (int)jCabecera["nrocli"], (string)jCabecera["razsoc"], (int)jCabecera["codven"], (int)jCabecera["condicion"], via, (int)jCabecera["viaid"], (int)jCabecera["sucursal"], sucursal, usuario, jUsuarioId, (decimal)jCabecera["neto"], (decimal)jCabecera["exento"], (decimal)jCabecera["bonitot"], (decimal)jCabecera["ivai"], (decimal)jCabecera["ivaidif"], (decimal)jCabecera["impint"], (decimal)jCabecera["percib"], (decimal)jCabecera["total"], (int)jCabecera["transpo"], vence, 0, 0, (string)jCabecera["direcc"], localidad, codpos, provin, jLocali, jCabecera["observa"].ToString(), pfe, (int)jCabecera["cond_vta"], "PAG.WEB", nroped, monfac, id, bonifcli, presup); if (presup != "") //boniftot bultos codpos facturado id kilos letra nroped nrotran puestotra tipodoc ntavta { //cComprobante.getControladorPresup().actualizarNroPed(,cabeceraPedido.id); } return(cabeceraPedido); }
public decimal getIvaTasaGral() { decimal tasa; using (GestionEntities bd = new GestionEntities()) { tasa = bd.configen.Single(a => a.empresa == empresaid).ivatasagral; } return tasa; }
internal RequestHTTP getCobranzasPorVendedor(int empresa, int codven, bool cotizaciones, string desde, string hasta, int group) { var req = new RequestHTTP(); string qCotizaciones = ""; string labelNombre = ""; string groupb = ""; string order = ""; try { if (cotizaciones) { qCotizaciones = " and clicta.tipdoco <> 'CT'"; } string consulta = "select sum(netocob) total, " + labelNombre + ", max(vende.codven) codven " + "from clicta " + "left join cliente on cliente.nrocli = clicta.nrocli " + "left join vende on vende.codven = cliente.codven " + "where empresa = " + empresa + " and fecha >= '" + desde + "' and fecha <= '" + hasta + "' and clicta.tipodoc = 'RC' and anulado = 0 " + "and vende.codven = " + codven + qCotizaciones + "group by " + groupb + "having sum(netocob) <> 0 " + "order by " + order; switch (group) { case 1: //agrupado por dia labelNombre = "convert(char(10),fecha,103) label, max(vende.nombre) nombre"; groupb = " fecha "; order = " fecha "; break; case 2: //agrupado por semana labelNombre = "convert(varchar,DATEPART(wk, fecha))+'/'+convert(varchar,year(fecha)) label, max(vende.nombre) nombre"; groupb = " DATEPART(wk, fecha), year(fecha) "; order = " year(fecha), DATEPART(wk, fecha) "; break; case 3: //agrupado x mes labelNombre = " convert(varchar,month(fecha))+'/'+ convert(varchar,year(fecha)) label, max(vende.nombre) nombre "; groupb = " month(fecha), year(fecha) "; order = " year(fecha), month(fecha) "; break; } using (GestionEntities bd = new GestionEntities()) req.objeto = bd.Database.SqlQuery <ventasVendedor>(consulta).ToList(); return(req); } catch (Exception e) { return(req.falla(e)); } }
public configen GetConfigen(int empresaid) { try { using (GestionEntities bd = new GestionEntities()) return(bd.configen.Single(a => a.empresa == empresaid)); } catch (Exception) { return(null); } }
public List<via> getVia() { try { using (GestionEntities bd = new GestionEntities()) return bd.via.ToList(); } catch (Exception) { return null; } }
public int getEmpresaNom(string nombre, string token) { if (!ControladorToken.comprobarToken(token)) { return -1; } using (GestionEntities bd = new GestionEntities()) { return bd.empresa.Single(a => a.empresa1 == nombre).id; } }
public List<conceptosincluidos> getConceptos() { try { using (GestionEntities bd = new GestionEntities()) return bd.conceptosincluidos.ToList(); } catch (Exception) { return null; } }
public empresa getEmpresa(int empresaid) { try { using (GestionEntities bd = new GestionEntities()) { return(bd.empresa.Single(a => a.id == empresaid)); } } catch (Exception) { return(null); } }
public int getUsuarioNombre(string nombre, string token) { if (!ControladorToken.comprobarToken(token)) { return -1; } using (GestionEntities bd = new GestionEntities()) { return bd.passwd.Single(a => a.usuario == nombre).idusuario; } }
public int getUsuarioNombre(string nombre) { try { using (GestionEntities bd = new GestionEntities()) { return(bd.passwd.Single(a => a.usuario == nombre).idusuario); } } catch (Exception) { return(0); } }
public List <presupc> getPresupNrocli(int nrocli) { try { using (GestionEntities bd = new GestionEntities()) { return(bd.presupc.Where(a => a.nrocli == nrocli).ToList()); } } catch (Exception) { return(null); } }
public PedidoDet(stocks stock, PedidoCab cabecera, int item) { List <artasoc> artasoc; using (GestionEntities bd = new GestionEntities()) artasoc = bd.artasoc.Where(a => a.codpro == stock.codpro && a.componen == stock.asociado).ToList(); if (artasoc.Count == 0) { this.canasoc = 0; } else { this.canasoc = Convert.ToInt32(artasoc.First().cantid *stock.cantidad); } this.cabeceraid = cabecera.id; this.item = Convert.ToInt16(item); this.articulo = stock.codpro; this.descri = stock.descri; this.cantidad = stock.cantidad; this.parafecha = stock.parafecha; this.pendientes = stock.cantidad; this.preparado = 0; this.precio = stock.precioVenta; this.precorig = 0;//rrrrrrrrrrrr this.bonif = stock.bonif; this.bonif1 = stock.bonif1; this.total = (this.precio * this.cantidad) + impint - this.precio * this.cantidad * stock.bonif / 100 - this.precio * this.cantidad * stock.bonif1 / 100; this.impint = stock.impint; this.orden = 0;//aaaaaaaaaaa this.marca = stock.marca; this.rubro = stock.rubro; this.nropro = stock.proveed; this.asociado = stock.asociado; this.detalle = stock.detalle;//aaaaa this.precioesp = 0; this.envase = stock.envase; this.unimed = stock.unimed; this.moneda = cabecera.monfac; this.ivaporc1 = Convert.ToDecimal(stock.iva); this.ivaporc2 = 0; this.deta = ""; this.listo = false; this.codorigi = ""; this.uxbulto = stock.uxbulto; this.costoest = 0; this.bajostk = false; this.impiva1 = stock.getIvaIGeneral(ControladorTotales.getCTotales().getIvaTasaGral()); this.impiva2 = stock.getIvaIDif(ControladorTotales.getCTotales().getIvaTasaGral()); }
public List <presupc> getPresupRazon(string razon) { try { using (GestionEntities bd = new GestionEntities()) { return(bd.presupc.Where(a => a.razsoc.Contains(razon)).ToList()); } } catch (Exception) { return(null); } }
public List <PedidoCab> getPedidos() { try { using (GestionEntities bd = new GestionEntities()) { return(bd.PedidoCab.Where(d => d.id > 126000).ToList()); } } catch (Exception) { return(null); } }
public List <PedidoDet> getItemPedido(int id) { try { using (GestionEntities bd = new GestionEntities()) { return(bd.PedidoDet.Where(a => a.cabeceraid == id).ToList()); } } catch (Exception) { return(null); } }
internal List <PedPendientes> getPedidosPendientes(int nrocli, string codpro, string token) { using (GestionEntities bd = new GestionEntities()) { if (bd.token.Single().token1 == token) { return(bd.Database.SqlQuery <PedPendientes>("select pedidocab.id, punto, nroped numero, fechaing fecha, articulo, descri, pendientes cantidad, ocompra from pedidocab left join pedidodet on pedidodet.cabeceraid = pedidocab.id where nrocli = " + nrocli + " and articulo like '" + codpro + "' and pendientes > 0").ToList()); } else { throw new Exception(); } } }
public RequestHTTP finalizarPresupuesto(JObject cabydet) { var req = new RequestHTTP(); try { var jCabecera = (JObject)cabydet["cabecera"]; int punto = (int)jCabecera["punto"], empresaid = (int)jCabecera["empresa"]; var jDetalle = cabydet["lista"]; decimal bonifcli = (decimal)cabydet["bonifcli"]; presupc cabecera = armarCabecera(jCabecera, bonifcli); List <presupd> detalle = armarDetalle(jDetalle, cabecera, bonifcli); using (GestionEntities bd = new GestionEntities()) { bd.presupc.Add(cabecera); foreach (presupd p in detalle) { bd.presupd.Add(p); } var factu = bd.factura.Single(a => a.PUNTO == punto && a.EmpresaId == empresaid); bd.factura.Attach(factu); factu.PRESUP++; if (!Convert.ToBoolean(bd.SaveChanges())) { throw new Exception(); } req.objeto = new compi(cabecera.numero, cabecera.punto, cabecera.tipodoc, cabecera.letra, cabecera.id); return(req); } } catch (DbEntityValidationException dbEx) { StreamWriter sw = new StreamWriter("C:/Users/usuario/Desktop/error.txt"); //Close the file foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { sw.WriteLine("Property:" + validationError.PropertyName + " Error:" + validationError.ErrorMessage); } } sw.Close(); return(req.falla(new Exception())); } }