public ActionResult Guardar(FormCollection post) { proveedores nuevo = new proveedores(); nuevo.nombre_proveedor = (string)post["nombre"]; nuevo.nombre_contacto = (string)post["nombreContacto"]; nuevo.correo_contacto = (string)post["correoContacto"]; nuevo.telefono = (string)post["telefonoContacto"]; nuevo.direccion = (string)post["dirProveedor"]; nuevo.razonsocial = (string)post["rSocial"]; nuevo.rut = (string)post["rutProv"]; proveedores.agregarProveedor(nuevo); return RedirectToAction("todos"); }
public ActionResult editar(string id) { if (Session["nombre"] != null && (Session["rol"].ToString().Equals("adquisiciones") || Session["rol"].ToString().Equals("admin"))) { proveedores tdato = new proveedores().getProveedor(id); if (tdato.nombre_proveedor != null) { return View(tdato); } return RedirectToAction("Index", "Home"); } else { return RedirectToAction("Index", "Home"); } }
public static void agregarProveedor(proveedores nuevo) { SqlConnection cnx = conexion.crearConexion(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cnx; cmd.CommandText = "INSERT INTO proveedores VALUES(@nombre_proveedor,@nombre_contacto," + "@correo_contacto,@telefono,@direccion,@razon_social,@rut)"; cmd.Parameters.Add("@nombre_proveedor", SqlDbType.VarChar).Value = nuevo.nombre_proveedor; cmd.Parameters.Add("@nombre_contacto", SqlDbType.VarChar).Value = nuevo.nombre_contacto; cmd.Parameters.Add("@correo_contacto", SqlDbType.VarChar).Value = nuevo.correo_contacto; cmd.Parameters.Add("@telefono", SqlDbType.VarChar).Value = nuevo.telefono; cmd.Parameters.Add("@direccion", SqlDbType.VarChar).Value = nuevo.direccion; cmd.Parameters.Add("@razon_social", SqlDbType.VarChar).Value = nuevo.razonsocial; cmd.Parameters.Add("@rut", SqlDbType.VarChar).Value = nuevo.rut; cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); cnx.Close(); }
public ActionResult GuardarEditar(FormCollection form) { if (Session["nombre"] != null && (Session["rol"].ToString().Equals("adquisiciones") || Session["rol"].ToString().Equals("admin"))) { proveedores proveedor = new proveedores(); string id_old = form["nombreAnterior"];//old proveedores.borrarproveedor(id_old); //Actualizar producto.. proveedor.nombre_proveedor = (string)form["nombre"]; proveedor.nombre_contacto = (string)form["nombreContacto"]; proveedor.correo_contacto = (string)form["correoContacto"]; proveedor.telefono = (string)form["telefonoContacto"]; proveedor.direccion = (string)form["dirProveedor"]; proveedor.razonsocial = (string)form["rSocial"]; proveedor.rut = (string)form["rutProv"]; proveedores.agregarProveedor(proveedor); return RedirectToAction("todos"); } else { return RedirectToAction("Index", "Home"); } }
public static List<proveedores> obtenerTodos() { List<proveedores> retorno = new List<proveedores>(); SqlConnection cnx = conexion.crearConexion(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cnx; cmd.CommandText = "SELECT * from proveedores ORDER BY nombre_proveedor ASC"; cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { proveedores proveedor = new proveedores(); proveedor.nombre_proveedor = (string)dr["nombre_proveedor"]; proveedor.nombre_contacto = (string)dr["nombre_contacto"]; proveedor.correo_contacto = (string)dr["correo_contacto"]; proveedor.telefono = (string)dr["telefono"]; proveedor.direccion = (string)dr["direccion"]; proveedor.razonsocial = (string)dr["razon_social"]; proveedor.rut = (string)dr["rut"]; retorno.Add(proveedor); } cnx.Close(); return retorno; }
public proveedores getProveedor(string id) { SqlConnection cnx = conexion.crearConexion(); proveedores tdato = new proveedores(); try { SqlCommand cmd = new SqlCommand(); cmd.Connection = cnx; string sqlcmd = string.Empty; sqlcmd = "select * "; sqlcmd += "from proveedores "; sqlcmd += "where ( nombre_proveedor = '" + id + "')"; cmd.CommandText = sqlcmd; cmd.CommandType = CommandType.Text; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { tdato.nombre_proveedor = (string)dr["nombre_proveedor"]; tdato.nombre_contacto = (string)dr["nombre_contacto"]; tdato.correo_contacto = (string)dr["correo_contacto"]; tdato.telefono = (string)dr["telefono"]; tdato.direccion = (string)dr["direccion"]; tdato.razonsocial = (string)dr["razon_social"]; tdato.rut = (string)dr["rut"]; } dr.Close(); } catch (Exception) { } cnx.Close(); return tdato; }
public static List<ordenCompraReporte> convertirEnDatosOrdenCompraReporte(orden_compra ordenCompra) { List<ordenCompraReporte> retorno = new List<ordenCompraReporte>(); datosEmpresa DatosEmpresa = datosEmpresa.obtenerDatos(); List<detalle_ordencompra> detalle = detalle_ordencompra.obtenerTodas(ordenCompra.numero_orden); nota notaOrden = nota.obtenerNota(ordenCompra.numero_orden); usointerno_oc usoInterno = usointerno_oc.obtenerUsointerno(ordenCompra.numero_orden); proveedores proveedor = new proveedores().getProveedor(ordenCompra.id_proveedor); //Para cada item del detalle se crea un elemento for (int i = 0; i < detalle.Count; i++) { ordenCompraReporte temp = new ordenCompraReporte(); temp.numeroOrdenCompra = ordenCompra.numero_orden; temp.fecha = ordenCompra.fecha; temp.rutEmpresa = DatosEmpresa.rut; temp.giroEmpresa = DatosEmpresa.giro; temp.direccionEmpresa = DatosEmpresa.direccion; temp.telefonoEmpresa = DatosEmpresa.telefono; temp.correoEmpresa = DatosEmpresa.correo; temp.nombreEmpresaPara = ordenCompra.id_proveedor; temp.rutEmpresaPara = proveedor.rut; temp.giroEmpresaPara = proveedor.razonsocial; temp.direccionEmpresaPara = proveedor.direccion; temp.telefonoEmpresaPara = proveedor.telefono; temp.cantidad = detalle[i].cantidad_item.ToString(); temp.unidad = detalle[i].unidad; temp.detalle = detalle[i].id_item; temp.precio = "$" + new formatearString().valoresPesos(detalle[i].precio_unitario.ToString()); temp.montoTotal = "$" + new formatearString().valoresPesos((detalle[i].precio_unitario * detalle[i].cantidad_item).ToString()); temp.subtotal = "$" + new formatearString().valoresPesos(ordenCompra.sub_total); temp.iva = "$" + new formatearString().valoresPesos(ordenCompra.iva); temp.totalPagar = "$" + new formatearString().valoresPesos(ordenCompra.total); //Nota temp.sirvaseEntregar = notaOrden.donde; temp.direccionEntregar = notaOrden.dir_entrega; temp.transporteCuentaEntregar = notaOrden.transporte; temp.formaPagoEntregar = notaOrden.cuenta; temp.plazoEntregaEntregar = notaOrden.plazo_entrega; //Uso Interno temp.nombreObraUsoInterno = usoInterno.faena; temp.comunaUsoInterno = usoInterno.comuna; temp.observacionesUsoInterno = usoInterno.observacion; temp.emRevisadoPorUsoInterno = usuarios.obtenerUsuario(usoInterno.revisadoPor).nombreCompleto; temp.item = usoInterno.item; temp.presupuesto = usoInterno.presupuesto; temp.OC = usoInterno.oc; temp.saldo = usoInterno.saldo; temp.observacion = ordenCompra.observacion; if (ordenCompra.esReeemplazada()) { temp.reemplazada = "true"; temp.numeroReemplaza = ordenCompra.obtenerNumeroOrdenQueReemplaza(); } else { temp.reemplazada = "false"; } if (ordenCompra.reemplaza()) { temp.reemplaza = "true"; temp.numeroReemplazada = ordenCompra.obtenerNumeroOrdenReemplazada(); } else { temp.reemplaza = "false"; } retorno = agregarParaListaSinRepetir(retorno, temp); } return retorno; }