public static string Busca_Descripcion(string id) { Conexion conn = new Conexion(); DataSet Producto_ = conn.Buscar_Mostrar("Producto", "Producto" + "= " + id); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Producto_.GetXml()); XmlNodeList _Producto = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList lista_producto = ((XmlElement)_Producto[0]).GetElementsByTagName("Producto_x003D__x0020_" + id); DataSet Bodega_ = conn.Buscar_Mostrar("Bodega", "Producto" + "= " + id); XmlDocument xBod = new XmlDocument(); xBod.LoadXml(Bodega_.GetXml()); XmlNodeList _Bodega = xBod.GetElementsByTagName("NewDataSet"); XmlNodeList Cantidad = ((XmlElement)_Bodega[0]).GetElementsByTagName("Cantidad"); XmlNodeList nDescripcion = ((XmlElement)lista_producto[0]).GetElementsByTagName("Descripcion"); string[] producto = new string[2]; producto[0] = nDescripcion[0].InnerText; producto[1] = Cantidad[0].InnerText; string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(producto); return(json); }
public static bool Add(string producto, string cantidad, string precio, string metros) { Conexion conn = new Conexion(); int ds = conn.Count("Select count(producto) from [Inventario] where producto=\'" + producto + "\';"); if (ds == 0) { Inv_Bodega(producto, cantidad); return(conn.Crear("Inventario", "Sucursal, Producto, Cantidad, Precio, Metros_Cuadrados ", "1 ," + producto + "," + cantidad + "," + precio + "," + metros)); } else { Inv_Bodega(producto, cantidad); DataSet Producto_ = conn.Buscar_Mostrar("Inventario", "Producto" + "= " + producto); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Producto_.GetXml()); XmlNodeList _Producto = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList cant = ((XmlElement)_Producto[0]).GetElementsByTagName("Cantidad"); XmlNodeList metros_cuad = ((XmlElement)_Producto[0]).GetElementsByTagName("Metros_Cuadrados"); string metros_cuadrados = metros_cuad[0].InnerText; string cantid = cant[0].InnerText; decimal metros1 = Convert.ToDecimal(metros_cuadrados, CultureInfo.CreateSpecificCulture("en-US")); decimal metros2 = Convert.ToDecimal(metros, CultureInfo.CreateSpecificCulture("en-US")); decimal metrostotales = metros1 + metros2; return(conn.Modificar("Inventario", "Cantidad =" + (Convert.ToInt64(cantid) + Convert.ToInt64(cantidad)) + ", Metros_Cuadrados=" + Convert.ToString(metrostotales).Replace(",", "."), "Producto=" + producto)); } }
public static bool Rest(string producto, string cantidad) { Conexion conn = new Conexion(); int ds = conn.Count("Select count(producto) from [Bodega] where producto=\'" + producto + "\';"); if (ds == 0) { return(conn.Crear("Bodega", "Producto, Cantidad ", "\'" + producto + "\'," + cantidad)); } else { DataSet Producto_ = conn.Buscar_Mostrar("Bodega", "Producto" + "= " + producto); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Producto_.GetXml()); XmlNodeList _Producto = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList cant = ((XmlElement)_Producto[0]).GetElementsByTagName("Cantidad"); string cantid = cant[0].InnerText; if (Convert.ToInt64(cantidad) > Convert.ToInt64(cantid)) { return(false); } else { return(conn.Modificar("Bodega", "Cantidad =" + (Convert.ToInt64(cantid) - Convert.ToInt64(cantidad)), "Producto=" + producto)); } } }
public static void Inv_Bodega(string producto, string cantidad) { Conexion conn = new Conexion(); DataSet Producto_ = conn.Buscar_Mostrar("Bodega", "Producto" + "= " + producto); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Producto_.GetXml()); XmlNodeList _Producto = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList cant = ((XmlElement)_Producto[0]).GetElementsByTagName("Cantidad"); string cantid = cant[0].InnerText; conn.Modificar("Bodega", "Cantidad =" + (Convert.ToInt64(cantid) - Convert.ToInt64(cantidad)), "Producto=" + producto); }
public static string BuscarRol(string id) { Conexion conn = new Conexion(); DataSet roles = conn.Buscar_Mostrar("Rol", "Rol" + "= " + id); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(roles.GetXml()); XmlNodeList Roles = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList lista = ((XmlElement)Roles[0]).GetElementsByTagName("Rol_x003D__x0020_" + id); XmlNodeList nNombre = ((XmlElement)lista[0]).GetElementsByTagName("Nombre"); return(nNombre[0].InnerText); }
public static string Busca(string idcliente) { Conexion conexion = new Conexion(); DataSet cliente; string respuesta = ""; cliente = conexion.Buscar_Mostrar("cliente", "cliente=" + idcliente); if (cliente.Tables[0].Rows.Count > 0) { foreach (DataRow item in cliente.Tables[0].Rows) { respuesta += item["nombre"].ToString() + "," + item["nit"].ToString() + "," + item["apellido"].ToString() + "," + item["cliente"].ToString(); } return(respuesta); } return("0"); }
public static string BuscarUsuario(string id) { Conexion conn = new Conexion(); DataSet Usuario = conn.Buscar_Mostrar("Usuario", "Usuario" + "= " + id); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Usuario.GetXml()); XmlNodeList Cliente = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList lista = ((XmlElement)Cliente[0]).GetElementsByTagName("Usuario_x003D__x0020_" + id); XmlNodeList nNick = ((XmlElement)lista[0]).GetElementsByTagName("NickName"); XmlNodeList nNombre = ((XmlElement)lista[0]).GetElementsByTagName("Nombre"); XmlNodeList nApellido = ((XmlElement)lista[0]).GetElementsByTagName("Apellido"); XmlNodeList nDpi = ((XmlElement)lista[0]).GetElementsByTagName("Dpi"); XmlNodeList nPass = ((XmlElement)lista[0]).GetElementsByTagName("Contrasenia"); XmlNodeList nRol = ((XmlElement)lista[0]).GetElementsByTagName("Rol"); string[] usuario = new string[6]; usuario[0] = nNick[0].InnerText; usuario[1] = nNombre[0].InnerText; usuario[2] = nRol[0].InnerText; usuario[3] = nApellido[0].InnerText; if (nDpi.Count == 0) { //si no tiene nit usuario[4] = ""; } else { usuario[4] = nDpi[0].InnerText; } usuario[5] = nPass[0].InnerText; string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(usuario); return(json); }
public static string Busca_Datos(string id) { Conexion conn = new Conexion(); DataSet Producto_ = conn.Buscar_Mostrar("Producto", "Producto" + "= " + id); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Producto_.GetXml()); XmlNodeList _Producto = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList lista_producto = ((XmlElement)_Producto[0]).GetElementsByTagName("Producto_x003D__x0020_" + id); DataSet Bodega_ = conn.Buscar_Mostrar("Bodega", "Producto" + "= " + id); XmlDocument xBod = new XmlDocument(); xBod.LoadXml(Bodega_.GetXml()); XmlNodeList _Bodega = xBod.GetElementsByTagName("NewDataSet"); XmlNodeList Cantidad = ((XmlElement)_Bodega[0]).GetElementsByTagName("Cantidad"); XmlNodeList nDescripcion = ((XmlElement)lista_producto[0]).GetElementsByTagName("Descripcion"); XmlNodeList nTipo = ((XmlElement)lista_producto[0]).GetElementsByTagName("Tipo"); DataSet Tipo_ = conn.Buscar_Mostrar("Tipo", "Tipo" + "= " + nTipo[0].InnerText); XmlDocument xTipo = new XmlDocument(); xTipo.LoadXml(Tipo_.GetXml()); XmlNodeList _Tipo = xTipo.GetElementsByTagName("NewDataSet"); XmlNodeList Tipo_Descripcion = ((XmlElement)_Tipo[0]).GetElementsByTagName("Descripcion"); DataSet Inventario = conn.Buscar_Mostrar("Inventario", "Producto" + "= " + id); XmlDocument xInventario = new XmlDocument(); xInventario.LoadXml(Inventario.GetXml()); string verifica = Inventario.GetXml(); string precio; if (verifica == "<NewDataSet />") { precio = "0"; } else { precio = "1"; } string[] producto = new string[4]; producto[0] = nDescripcion[0].InnerText; producto[1] = Cantidad[0].InnerText; producto[2] = Tipo_Descripcion[0].InnerText; producto[3] = precio; string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(producto); return(json); }
public static string BuscarCliente(string id) { Conexion conn = new Conexion(); DataSet roles = conn.Buscar_Mostrar("Cliente", "Cliente" + "= " + id); string[] cliente = new string[5]; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(roles.GetXml()); XmlNodeList Cliente = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList lista = ((XmlElement)Cliente[0]).GetElementsByTagName("Cliente_x003D__x0020_" + id); XmlNodeList nNombre = ((XmlElement)lista[0]).GetElementsByTagName("Nombre"); XmlNodeList nNit = ((XmlElement)lista[0]).GetElementsByTagName("Nit"); XmlNodeList nApellido = ((XmlElement)lista[0]).GetElementsByTagName("Apellido"); XmlNodeList nDireccion = ((XmlElement)lista[0]).GetElementsByTagName("Direccion"); XmlNodeList nTelefono = ((XmlElement)lista[0]).GetElementsByTagName("Telefono"); cliente[0] = nNombre[0].InnerText; if (nNit.Count == 0) //si no tiene nit { cliente[1] = ""; } else { cliente[1] = nNit[0].InnerText; } if (nApellido.Count == 0) //si no tiene apellido { cliente[2] = ""; } else { cliente[2] = nApellido[0].InnerText; } if (nDireccion.Count == 0) //si no tiene direccion { cliente[3] = ""; } else { cliente[3] = nDireccion[0].InnerText; } if (nTelefono.Count == 0) //si no tiene telefono { cliente[4] = ""; } else { cliente[4] = nTelefono[0].InnerText; } string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cliente); return(json); }
public static string BuscarProducto(string id) { Conexion conn = new Conexion(); DataSet Producto_ = conn.Buscar_Mostrar("Producto P", "Producto" + "= " + id); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(Producto_.GetXml()); XmlNodeList _Producto = xDoc.GetElementsByTagName("NewDataSet"); XmlNodeList lista_producto = ((XmlElement)_Producto[0]).GetElementsByTagName("Producto_x003D__x0020_" + id); XmlNodeList nAbreviatura = ((XmlElement)lista_producto[0]).GetElementsByTagName("Abreviatura"); XmlNodeList nDescripcion = ((XmlElement)lista_producto[0]).GetElementsByTagName("Descripcion"); XmlNodeList nTipo = ((XmlElement)lista_producto[0]).GetElementsByTagName("Tipo"); DataSet Tipo_Pro = conn.Buscar_Mostrar("Tipo", "Tipo" + "= " + nTipo[0].InnerText); XmlDocument xDocu = new XmlDocument(); xDocu.LoadXml(Tipo_Pro.GetXml()); XmlNodeList Tipopro = xDocu.GetElementsByTagName("NewDataSet"); XmlNodeList lista_tipo = ((XmlElement)Tipopro[0]).GetElementsByTagName("Tipo_x003D__x0020_" + nTipo[0].InnerText); XmlNodeList nDescripcionTipo = ((XmlElement)lista_tipo[0]).GetElementsByTagName("Descripcion"); XmlNodeList nPorcentaje = ((XmlElement)lista_producto[0]).GetElementsByTagName("Porcentaje"); XmlNodeList nLargo = ((XmlElement)lista_producto[0]).GetElementsByTagName("Largo"); XmlNodeList nAncho = ((XmlElement)lista_producto[0]).GetElementsByTagName("Ancho"); XmlNodeList nMarca = ((XmlElement)lista_producto[0]).GetElementsByTagName("Marca"); string[] producto = new string[8]; producto[0] = nAbreviatura[0].InnerText; producto[1] = nDescripcion[0].InnerText; producto[2] = nTipo[0].InnerText; if (nPorcentaje.Count == 0) { producto[3] = ""; } else { producto[3] = nPorcentaje[0].InnerText; } if (nLargo.Count == 0) { producto[4] = ""; } else { producto[4] = nLargo[0].InnerText; } if (nAncho.Count == 0) { producto[5] = ""; } else { producto[5] = nAncho[0].InnerText; } producto[6] = nMarca[0].InnerText; producto[7] = nDescripcionTipo[0].InnerText; string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(producto); return(json); }